简体   繁体   中英

InitializeCriticalSectionEx Not Located In KERNEL32.Dll

I am trying to build a dll project in VS2015 to deploy it on Windows XP. It works on Windows 7, but gives an error on Windows XP SP3:

The procedure entry point InitializecriticalSectionEx could not be located in the dynaic link libray KERNEL32.dll

I have build the library with: Configuration=Release;Platform=x86;PlatformToolset=v140_xp;

Unfortunatelly, the InitializeCriticalSectionEx function does not exist in the XP version of Kernel32.dll, even with SP3 installed. It was not introduced until Vista. It appears the driver you are using is not fully compatible with XP.

Is it possibible to solve this problem without downgrading the build PlatformToolset?

Since you need your DLL to run on an OS where InitializeCriticalSectionEx() is not available, you cannot static link to the function at compile time. That is why you are getting the entry point error.

Instead, you will have to load the InitializeCriticalSectionEx() function dynamically at runtime using GetProcAddress() (or the linker's delay-load feature , which uses GetProcAddress() internally).

If the InitializeCriticalSectionEx() function fails to load at runtime, your code can then fallback to something else, like InitializeCriticalSection() or even InitializeCriticalSectionAndSpinCount() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM