开发者

Dynamically loading registry function on Windows 7?

I am dynamically loading several registry API's from the library Advapi32.dll. Under Windows XP and Vista everything is OK. Under Windows 7 I keep getting the error The parameter is incorrect and in some cases (like RegCloseKey) my application crashes.

The code I am using is the usual:

// RegCreateKeyEx
typedef LONG (WINAPI *MyRegCreateKeyEx)(HKEY, LPCTSTR, DWORD, LPTSTR, DWORD, REGSAM, LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD);
MyRegCreateKeyEx LoadedRegCreateKeyEx;

then I use LoadLibrary to load Advapi.dll and GetProcAddress to find the address to RegCreateKeyEx. Like:

开发者_如何学GoLoadedRegCreateKeyEx = (MyRegCreateKeyEx)GetProcAddress(LibHandle, "RegCreateKeyEx");

Everything returns OK, there are no errors and the pointers seem to be correct, yet it doesn't work under Windows 7. Any ideas? Did anything change? Is there a different way to do this for Windows 7?

Thank you jess.

EDIT: It seems that this problem extends to all kind of API's on windows 7. Any idea?


You might want to specify the correct version when you call GetProcAddress, i.e., A for ANSI and W for UNICODE.


The problem was getting the right offset from the library. Once I got it everything worked correctly

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜