Reputation: 43
How would i find the current drive name where my executable file is running?
I want to use WritePrivateProfileString() for saving a string in .ini file. I want to make the file name to be generic, as the hardcoding the full path or drive name is not a good idea.
Can anyone please tell me how to retrieve the current drive name to use in this API.
I am using this API something like this:-
WritePrivateProfileString(_T("device"), _T("i2c_address"), temp, _T("D:\log.ini"));
I don't want to hardcode D over here please let me know how can I make this generic.
Upvotes: 0
Views: 248
Reputation: 7521
I believe you can get the full absolute path of the running module using GetModuleFileName, for the active module you use:
GetModuleFileName(NULL,Buffer,BufferLength);
Upvotes: 1