Create a DLL using VC ++ 6.0

Source: Internet
Author: User

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.