a problem was encountered when manipulating the database: Win7 SP1 on the Win7 SP1 the following versions of the ADO program are not running . (The dynamic file required under the WIN7 system is not the same as the dynamic link library required by the XP system.) dynamic-link libraries need to be loaded based on the version of the system. )
Under the Win7 system:
Required dynamic-link libraries
#import "MSADO15. DLL "rename_namespace (" Adowe ") Rename (" EOF "," Endoffile ")
Win XP under
#import "Msado60.tlb" Rename_namespace ("Adowe") Rename ("EOF", "adoeof")
Add the following statement before defining the class to implement versioning:
#if ((_win32_winnt) = = (_WIN32_WINNT_WINXP))
#import "Msado60.tlb" rename_namespace ("Adowe") rename ("EOF", "adoeof")
#elif ((_win32_winnt) = = (_win32_winnt_win7))
#import "MSADO15. DLL "rename_namespace (" Adowe ")
#endif
So that the program can be copied from the Win7 system into the XP system can open the database normally.
To test version control directives in the console environment:
#include <windows.h>
#include <iostream>
using namespace Std;
#if ((_win32_winnt) = = (_WIN32_WINNT_WINXP))
int version=1; //precompilation defines a global variable outside of precompilation and then assigns a value in the precompiled statement//. Assigning values to variables occurs during the compilation process, and precompilation is just a simple replacement.
#elif ((_win32_winnt) = = (_win32_winnt_win7))
int version=2;
#else
int version=3;
#endif
/*
Error wording:
int Version;
#if ((_win32_winnt) = = (_WIN32_WINNT_WINXP)) BR style= "font-size:24px" > version=1; //Unrecognized version type causes the global variable in the program to always be 0.
#elif ((_win32_winnt) = = (_WIN32_ winnt_win7))
version=2; //unrecognized version type
#else
VERSION=3; //unrecognized version type
#endif
*/
void Main ()
{
if (version==1)
cout<< "Window xp!" <<endl;
else if (version==2)
cout<< "Window 7" <<endl;
Else
cout<< "Undefined operating system" <<endl;
}
Running the program output under the Win7 system: Window 7
C + + calls different dynamic-link libraries based on the operating system version