User forums > General (but related to Code::Blocks)

Display resolution issue

<< < (2/2)

JoeH:
I gave the recommended "Get" function a try.  Even though I included the sysinfoapi.h file in the main header file, the code will not compile successfully.  I get a error stating "GetIntegratedDisplaySize was not declared in this scope".

Joe

ollydbg:
AI helps:


--- Code: ---#include <windows.h>
#include <iostream>

typedef HRESULT (WINAPI *GetIntegratedDisplaySize_t)(double*);

int main()
{
    HMODULE hKernelBase = LoadLibraryW(L"kernelbase.dll");
    if (!hKernelBase)
    {
        std::wcout << L"Failed to load kernelbase.dll\n";
        return 1;
    }

    auto GetIntegratedDisplaySize =
        (GetIntegratedDisplaySize_t)GetProcAddress(
            hKernelBase,
            "GetIntegratedDisplaySize"
        );

    if (!GetIntegratedDisplaySize)
    {
        std::wcout << L"API not available\n";
        return 1;
    }

    double size = 0.0;
    HRESULT hr = GetIntegratedDisplaySize(&size);

    if (SUCCEEDED(hr))
    {
        std::wcout << L"Integrated display size: "
                   << size
                   << L" inches\n";
    }

    FreeLibrary(hKernelBase);
}

--- End code ---

I can compile and run the program under msys2/mingw64/gcc.

Miguel Gimenez:
The quickest solution is adding libonecore.a to the linker.

Navigation

[0] Message Index

[*] Previous page

Go to full version