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 开发者_如何学Pythonthe 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.
精彩评论