Window Service Parameters from INI file
-
hi I wrote a service in which i want to pass some parameters from INI file but when i give the path as .\\TibcoTCPServer.ini it does not work but if i hard code the path it works fine. Can any body help me how can i pass the ini file path so that service will pick the parameters. Thanks Shailesh
-
hi I wrote a service in which i want to pass some parameters from INI file but when i give the path as .\\TibcoTCPServer.ini it does not work but if i hard code the path it works fine. Can any body help me how can i pass the ini file path so that service will pick the parameters. Thanks Shailesh
.\\TibcoTCPServer.ini is a relative path, which means it's relative to whatever happens to be the current working directory at the moment. Use
GetModuleFileName(NULL, ...)
instead to get the application's fully-qualified path, then replace the filename with TibcoTCPServer.ini.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
.\\TibcoTCPServer.ini is a relative path, which means it's relative to whatever happens to be the current working directory at the moment. Use
GetModuleFileName(NULL, ...)
instead to get the application's fully-qualified path, then replace the filename with TibcoTCPServer.ini.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
if i use GetModuleFinename(NULL..) I Get the Memory could not be read error. My Code is as BOOL FillParams() { CFileFind fileFinder; CIniReader m_IniFile; TCHAR Buffer[BUFSIZE]; DWORD dwRet,nSize; CString error; dwRet = GetModuleFileName(NULL,Buffer,nSize); if( dwRet == 0 ) { error.Format("Failed GetCurrentDirectory %d",GetLastError()); WriteToLog((LPSTR)(LPCTSTR)error); return 0; } WriteToLog(Buffer); // Here i am changing the path.. } But It is failing at GetModuleFineName function or crashing. Any Suggestion.. Thanks Shailesh
-
if i use GetModuleFinename(NULL..) I Get the Memory could not be read error. My Code is as BOOL FillParams() { CFileFind fileFinder; CIniReader m_IniFile; TCHAR Buffer[BUFSIZE]; DWORD dwRet,nSize; CString error; dwRet = GetModuleFileName(NULL,Buffer,nSize); if( dwRet == 0 ) { error.Format("Failed GetCurrentDirectory %d",GetLastError()); WriteToLog((LPSTR)(LPCTSTR)error); return 0; } WriteToLog(Buffer); // Here i am changing the path.. } But It is failing at GetModuleFineName function or crashing. Any Suggestion.. Thanks Shailesh
You've failed to inform the function of the size of the buffer.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
You've failed to inform the function of the size of the buffer.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
I did not indicate that the buffer itself was not large enough. Check your code again. Note the third parameter being passed to
GetModuleFileName()
.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
I did not indicate that the buffer itself was not large enough. Check your code again. Note the third parameter being passed to
GetModuleFileName()
.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen