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 <ansi_c.h>
#include<stdio.h>
#include <windows.h>//需要的API函数实际在winbase.h中定义
#include <formatio.h>
#include <userint.h>


//==============================================================================
// 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 <argument>\n", name);
    fprintf (stderr, "A short summary of the functionality.\n");
    fprintf (stderr, "    <argument>    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;
}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值