您的位置:首页 > 编程语言 > C语言/C++

学习VC++深入浅出——DLL的使用

2008-03-19 23:52 232 查看
 学习VC++深入浅出——DLL的使用


//#include <Windows.h>


//#include <stdio.h>




extern "C" _declspec(dllexport) int add(int a,int b)




...{


    return a+b;


}






_declspec(dllexport) int subtract(int a,int b)




...{


    return a-b;


}




/**//*


class _declspec(dllexport) Point


{


public:


    void output(int x,int y)


    {


        HWND hwnd = GetForegroundWindow();


        HDC hdc=GetDC(hwnd);


        char buf[20];


        memset(buf,0,20);


        sprintf(buf,"x=%d,y=%d",x,y);


        TextOut(hdc,0,0,buf,strlen(buf));


        ReleaseDC(hwnd,hdc);


    }


};


*/




_declspec(dllimport) int add(int a,int b);


_declspec(dllimport) int subtract(int a,int b);












extern int add(int a,int b);


extern int subtract(int a,int b);


//extern class Point;


//_declspec(dllimport) int add(int a,int b);


//_declspec(dllimport) int subtract(int a,int b);


//#include "..Dll1Dll1.h"




void CDllTestDlg::OnBtnAdd() 




...{


    // TODO: Add your control notification handler code here


    CString str;


    str.Format("5+3=%d",add(5,3));


    MessageBox(str);


}




void CDllTestDlg::OnBtnSubtract() 




...{


    // TODO: Add your control notification handler code here


    CString str;


    str.Format("5-3=%d",subtract(5,3));


    MessageBox(str);


}




void CDllTestDlg::OnBtnOutput() 




...{


    // TODO: Add your control notification handler code here


//    Point pt;


//    pt.output(5,3);


}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  vc++ dll class c