简体   繁体   中英

Load function at runtime in C++

I have following problem:

My program should decide at runtime to load an function (in this case GetExtendedTcpTable()) or not, because the method is not available in Windows 2000!? (can't start the software only in Windows 2000)

Thank you for your help!

greets leon22

You didn't quite specify your question, but I suppose that you want to load the function dynamically based on the OS version.

To determine the OS version, you can use GetVersionEx . To load a function dynamically, first use LoadLibrary to retrieve the module handle of its DLL, and then use GetProcAddress to retrieve a function pointer to the function. You will need to cast that function pointer to the correct prototype.

If the function is not available on a particular platform, you want to determine at compile time whether or not to load it not at runtime. During the configury of the build, you determine if the function is available and compile appropriately.

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