Labwindows 调用VS的dll

VS

extern "C" __declspec(dllexport) int  ShowNote(char *pszText)

{
//MessageBox(NULL, pszText, "提示", 0);
return 111;

}

labwindows

//==============================================================================
//
// Title:       CallDll
// Purpose:     A short description of the command-line tool.
//
// Created on:  2013/11/11 at 20:27:11 by guogang.
// Copyright:   Microsoft. All Rights Reserved.
//
//==============================================================================


//==============================================================================
// Include files


#include
#include
#include //需要的API函数实际在winbase.h中定义
#include
#include


//==============================================================================
// Constants


//==============================================================================
// Types


//==============================================================================
// Static global variables


//==============================================================================
// Static functions


/// HIFN  Explain how to use this command-line tool.
/// HIPAR name/The name of the command-line tool.
static void usage (char *name)
{
    fprintf (stderr, "usage: %s \n", name);
    fprintf (stderr, "A short summary of the functionality.\n");
    fprintf (stderr, "        is an argument\n");
    exit (1);
}


//==============================================================================
// Global variables


//==============================================================================
// Global functions


/// HIFN  The main entry-point function.
/// HIPAR argc/The number of command-line arguments.
/// HIPAR argc/This number includes the name of the command-line tool.
/// HIPAR argv/An array of command-line arguments.
/// HIPAR argv/Element 0 contains the name of the command-line tool.
/// HIRET Returns 0 if successful.


typedef int  DLLEXPORT(*DLLCdeclFunction)(char *pszText);  //定义函数指针


int main (int argc, char *argv[])
{
    HMODULE hinstLib;
DLLCdeclFunction DLLFunction= NULL;     
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;     

int status;
    char message[80];


hinstLib = LoadLibrary("vsdll.dll");//装载动态链接库mydll.dll  
if (hinstLib != NULL)//成功装载动态链接库mydll.dll  
    { 
       DLLFunction = (DLLCdeclFunction)GetProcAddress(hinstLib, (LPCSTR)"ShowNote");//取函数指针地址 


             // If the function address is valid, call the function. 
       if (fRunTimeLinkSuccess = (DLLFunction != NULL))//dll中有函数MyDLLCdeclFunction() 
  {
           // Fmt(message, "message via DLL function\n"); 
            printf("******* = %d",DLLFunction ("abcd"));//调用dll函数!!! 
  }
             // Free the DLL module 


       fFreeResult = FreeLibrary(hinstLib);//卸载动态链接库mydll.dll 
    } 
if (! fRunTimeLinkSuccess) 
{
       Fmt(message, "message via alternative method guo\n"); 
  MessagePopup ("CVI guo MessagePopup ", message);     
}

char c = getchar();
    return 0;
}


你可能感兴趣的:(大杂烩)