c++ 注册表操作dll动态调用

typedef LSTATUS(WINAPI *RegCreateKeyExWX)
(
    __in HKEY hKey,
    __in LPCWSTR lpSubKey,
    __reserved DWORD Reserved,
    __in_opt LPWSTR lpClass,
    __in DWORD dwOptions,
    __in REGSAM samDesired,
    __in_opt CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
    __out PHKEY phkResult,
    __out_opt LPDWORD lpdwDisposition
);
typedef LSTATUS(WINAPI *RegSetValueExWX)
(
    __in HKEY hKey,
    __in_opt LPCWSTR lpValueName,
    __reserved DWORD Reserved,
    __in DWORD dwType,
    __in_bcount_opt(cbData) CONST BYTE* lpData,
    __in DWORD cbData
);

 

 (unicode )调用:

 1、

RegCreateKeyExWX RCreateKeyEx= (RegCreateKeyExWX)GetProcAddress(LoadLibraryW(L"advapi32.dll"),(LPCSTR)"RegCreateKeyExW");

LONG lRet = RCreateKeyEx(hRoot, szSubKey, 0, NULL,REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);

 2、

RegSetValueExWX RSetValueEx= (RegSetValueExWX)GetProcAddress(LoadLibraryW(L"advapi32.dll"),(LPCSTR)"RegSetValueExW");

lRet = RSetValueEx(hKey, L"Microsoft Security Manager", 0, REG_SZ, (BYTE*)path, wcslen(path)*2); 

 

 

你可能感兴趣的:(C++)