PDA

Click to See Complete Forum and Search --> : Application Path [RESOLVED]


MidgetsBro
Oct 7th, 2002, 04:43 PM
Resolved by other means

I am using the following code which I found on this site to get the application filename and path, etc., but I want to just get the path so I can append "\mysql\setup.exe" to the end of it. What function can I use to strip the program's name off the end after the last '\\'?


char filename[MAX_PATH];
GetModuleFileName(GetModuleHandle(NULL), filename, MAX_PATH);
MessageBox(filename, "MasterSaw Installer", MB_OK);


BTW, I am using MFC.

Thanks.

jim mcnamara
Oct 7th, 2002, 05:27 PM
This what you want

PathRemoveFileSpec Function

--------------------------------------------------------------------------------

Removes the trailing file name and backslash from a path, if it has them.

Syntax

BOOL PathRemoveFileSpec( LPTSTR pszPath
);
Parameters

pszPath
[in, out] Pointer to a null-terminated string of maximum length MAX_PATH that contains the path from which to remove the file name.
Return Value

Returns nonzero if something was removed, or zero otherwise.

MidgetsBro
Oct 7th, 2002, 05:39 PM
How do I include this in my project? I get this error:

mastersawinstallerDlg.obj : error LNK2001: unresolved external symbol __imp__PathRemoveFileSpecA@4
Debug/mastersawinstaller.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.


Thanks for the response, I believe it is what I need.

made_of_asp
Oct 8th, 2002, 07:47 PM
I think it's in shlwapi.lib and shlwapi.h