As stated in the documentation for the IDirectDraw7::SetCooperativeLevel method, it states
You must use LoadLibrary to explicitly link to Ddraw.dll and then use GetProcAddress to access the SetCooperativeLevel method.
in the remarks. However when I attempt to do so (code below), it fails to work. Am I doing something wrong?
typedef HRESULT (*pSetCooperativeLevelFunc)(HWND, DWORD);
HMODULE ddrawLib = LoadLibrary(L"ddraw.dll");
pSetCooperativeLevelFunc SCL = (pSetCooperativeLevelFunc) GetProcAddress(
ddrawLib,
"SetCooperativeLevel"
);
if (SCL == NULL) {
// this happens
int error = GetLastError(); // 127 (ERROR_PROC_NOT_FOUND)
printf("Error getting SetCooperativeLevel function address: %i", error);
}
There is no exported
SetCooperativeLevelfunction in ddraw.dll. UseDUMPBINutility and check it yourself. You can getDirectDrawCreate/DirectDrawCreateExand similar functions usingGetProcAddress, but you can’t extract individual methods of COM object.Article is quite ridiculous and doesn’t make sense. Perhaps it was supposed to tell you to get
DirectDrawCreatefrom ddraw.dll or something like that, but there’s little reason to do that.Link with
ddraw.lib, callDirectDrawCreateand access methods provided by IDirectDraw7 interface.P.S. If you aren’t familiar with dumpbin, I’d suggest to learn at least basic usage of this utility.