Versuche SHGetSpecialFolderA zu laden.
Doch GetModuleFileNameA() gibt bei "Shell32.dll" nicht die Addresse,
sonder Fehler -> NULL. Habe das schon für CopyFileA geschrieben, bei dem alles funktioniert hat.
Code:
#include <Windows.h>
#include <ShlObj.h>
typedef
BOOL SHGetSpecialFolderPath_t(
HWND hwndOwner,
__out LPSTR lpszPath,
__in int csidl,
__in BOOL fCreate
/* Shell32.dll
TRUE if successful; otherwise, FALSE.
*/
);
bool dynamic_SHGetSpecialFolderPath(char* cPath)
{
HMODULE h_Load;
SHGetSpecialFolderPath_t* mySHGetSpecialFolderPath = 0;
h_Load = GetModuleHandleA((LPCTSTR)"Shell32.dll"); //<---
if (h_Load == false)
{
MessageBoxA(NULL,"failed","lol",0);
return false;
}
*(FARPROC*)&mySHGetSpecialFolderPath = GetProcAddress(h_Load, (LPCSTR)"SHGetSpecialFolderPathA");
mySHGetSpecialFolderPath(NULL,(LPSTR)cPath,CSIDL_APPDATA|CSIDL_FLAG_CREATE,0);
return true;
}