When including comctl32.lib causes "The ordinal 345 could not be found in the dynamic link library (xxxx.exe)"

Ahmed Osama 120 Reputation points
2023-02-26T15:44:04.55+00:00

When I insert this line:

#pragma comment(lib,"comctl32.lib")

it says:

"The ordinal 345 could not be found in the dynamic link library (xxxx.exe)"

And it compiles but doesn't run, how?

I'm about to create a Task Dialog

The sample of it compiles AND runs

reproduce:

create any project:

insert:

#pragma comment(lib, "comctl32.lib")

-

-

#include "commctrl.h"

TaskDialogIndirect(&tdc, (int *)2, NULL, NULL);

"Replace tdc with the name of your TASKDIALOGCONFIG variable name"

BOOM, ERROR at run time

with "Ordinal not found" returned by HRESULT of ShellExecute (which executes the application)

AND EVERY THREAD returns the same error.

Error Code: 0xc0000138

How I link to comctl32,lib correctly and without getting an error?

Windows development | Windows API - Win32
Developer technologies | C++
{count} votes

Accepted answer
  1. KingKong-4442 166 Reputation points
    2023-02-27T09:16:41.9433333+00:00

    You have to add the dependency, exactly as RLWA32 said. But even if you did that, I expected it to crash because of your second parameter "(int *)2". 2 certainly does not point to an int, as required by TaskDialogIndirect. Better:

    int idButton = 0;
    
    TaskDialogIndirect(&tdc, &idButton, NULL, NULL);
    
    

    Or if you don't need to know the button being pressed:

    TaskDialogIndirect(&tdc, NULL, NULL, NULL);
    
    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. RLWA32 49,641 Reputation points
    2023-02-26T16:24:57.6833333+00:00

    You need to manifest your application so that it loads V6 of the common controls.

    For example, include the following -

    #if defined _M_IX86
    	#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_IA64
    	#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_X64
    	#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #else
    	#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #endif
    
    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.