typedef HRESULT STDAPICALLTYPE AcquireDeveloperLicense(
_In_opt_ HWND hwndParent,
_Out_ FILETIME *pExpiration
);
HINSTANCE hDll = LoadLibrary(TEXT("WSClient.dll"));
AcquireDeveloperLicense *acquire_license = (AcquireDeveloperLicense*)GetProcAddress(hDll, "AcquireDeveloperLicense");
FILETIME *pExpiration = NULL;
HWND hwnd = GetConsoleWindow();
HRESULT result = acquire_license(hwnd, pExpiration);
答案 0 :(得分:1)
您正在AcquireDeveloperLicense()
的第二个参数中传递NULL指针。它希望您传入指向FILETIME
结构的指针以接收许可证的到期日期。 FILETIME
不是可选的。
请改为尝试:
typedef HRESULT (STDAPICALLTYPE *LPFN_AcquireDeveloperLicense)(
_In_opt_ HWND hwndParent,
_Out_ FILETIME *pExpiration
);
HINSTANCE hDll = LoadLibrary(TEXT("WSClient.dll"));
if (hDll)
{
LPFN_AcquireDeveloperLicense acquire_license = (LPFN_AcquireDeveloperLicense) GetProcAddress(hDll, "AcquireDeveloperLicense");
if (acquire_license)
{
FILETIME Expiration = {};
HWND hwnd = GetConsoleWindow();
HRESULT result = acquire_license(hwnd, &Expiration);
...
}
...
FreeLibrary(hDll);
}
答案 1 :(得分:0)
您需要提供指向您希望函数存储结果的变量的指针,而不是传递NULL
。由于AcquireDeveloperLicense
备注pExpiration
不是可选的 out 参数,而且NULL
不是有效值。
FILETIME expiration{};
HWND hwnd = GetConsoleWindow();
HRESULT result = acquire_license(hwnd, &expiration);