首页 > 代码库 > C++ builder调用vc编写的动态链接库的方法

C++ builder调用vc编写的动态链接库的方法

    //启动com库
    WSADATA Data_WSA;
    int nWSAStartup = WSAStartup(MAKEWORD(1, 1), &Data_WSA);
    if( nWSAStartup != 0 )
    {
        return;
    }

    //加载动态链接库
    AnsiString str= strPath + (AnsiString)"\\Net.dll";
    HINSTANCE handle = LoadLibrary(str.c_str());
    if (handle == NULL)
    {
        return;
    }

    //打开网口

    FARPROC lpFarProc;
    lpFarProc = GetProcAddress(handle,"OpenNet");
    long (*OpenNet)(char*,long);
    OpenNet = (long (__cdecl*)(char*,long))lpFarProc;
    long lSuccess = OpenNet("192.168.0.1", 8080);
    if (lSuccess != 0)
    {
        FreeLibrary(handle);
        return;
    }

    //释放动态链接库
    FreeLibrary(handle);

 

C++ builder调用vc编写的动态链接库的方法