There is a WinAPI function:
The GetModuleFileName function retrieves the fully qualified path for the specified module.

To specify the process that contains the module, use the GetModuleFileNameEx function.


DWORD GetModuleFileName(
HMODULE hModule,
LPTSTR lpFilename,
DWORD nSize
);

Parameters
hModule
[in] Handle to the module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path for the current module.
lpFilename
[out] Pointer to a buffer that receives a null-terminated string that specifies the fully-qualified path of the module. If the length of the path exceeds the size specified by the nSize parameter, the function succeeds, but the string is truncated to nSize and may not include a null-terminating character.
Windows NT/2000/XP: The path can have the prefix "\\?\", depending on how the module was loaded. For more information, see Naming a File.

nSize
[in] Size of the lpFilename buffer, in TCHARs.
Why can't you access the command line arguments?