Create the "Win32 dynamic-Link Library" project name "dll_1", click "finish", and select "an empty DLL project ".
Content in the "mydll. H" File
Extern "C" _ declspec (dllexport) int max (int A, int B );
Extern "C" _ declspec (dllexport) int min (int A, int B );
Content in "mydll. cpp"
# Include "mydll. H"
# Include <stdio. h>
Int max (int A, int B)
{
If (A> = B) return;
Else return B;
}
Int min (int A, int B)
{
Printf ("Min is called/n ");
If (A> = B) return B;
Else return;
}
Then. copy the Lib file to the directory of another project (the DLL project to be called. copy the DLL file to the DEBUG directory of another project (the DLL project to be called ).
Call another projectCodeAs follows:
# Pragma comment (Lib, "mydll. lib ")
Extern "C" _ declspec (dllimport) int max (int A, int B );
Extern "C" _ declspec (dllimport) int min (int A, int B );
# include
int main ()
{< br> int A;
A = min (8, 10 );
printf ("the comparison result is % d/N", a);
return 0;
}