资源简介
本例程是在CVI自带的simple添加调用mydll.dll的函数MyDLLCdeclFunction() 网上和CVI的例程很少,一般为调用LIB实例,但很多dll都是以*.dll提供的,故本例程很实用。
本例程主要是调用了三个Windows API函数LoadLibrary(),GetProcAddress(),FreeLibrary()
代码片段和文件信息
/* A simple example of using a uir in a dll created both in cvi or an
* external compiler.
*/
/* Include files needed to compile DLL */
#include
#include /* needed if linking DLL in external compiler; harmless otherwise */
#include
#include “dlluir.h“
static long int status = 0;
static int lightVal = 0 panelHandle;
BOOL __stdcall DllMain (HINSTANCE hinstDLL DWORD fdwReason LPVOID lpvReserved)
{
/* The DllMain function is called when ever the DLL is loaded and */
/* unloaded. Place Initialization code for the DLL in this function. */
if (fdwReason == DLL_PROCESS_ATTACH) {
/* Place any initialization which needs to be done when the DLL */
/* is loaded here. */
if (InitCVIRTE (hinstDLL 0 0) == 0) /* needed if linking DLL in external compiler; harmless otherwise */
return 0; /* out of memory */
status = 100;
} else if (fdwReason == DLL_PROCESS_DETACH) {
/* Place any clean-up which needs to be done when the DLL */
/* is unloaded here. */
CloseCVIRTE (); /* needed if linking DLL in external compiler; harmless otherwise */
}
/* return FALSE to abort if initialization fails */
return TRUE;
}
BOOL __stdcall DllEntryPoint (HINSTANCE hinstDLL DWORD fdwReason LPVOID lpvReserved)
{
return DllMain(hinstDLL fdwReason lpvReserved);
}
void DLLEXPORT RunDllUI (void)
{
/* Call this function from the appropriate place in your code */
/* to load and display startup panels. */
panelHandle = LoadPanelEx (0 “dlluir.uir“ PANEL __CVIUserHInst);
DisplayPanel (panelHandle);
RunUserInterface ();
}
int CVICALLBACK CloseUICallback (int panel int control int event
void *callbackData int eventData1 int eventData2)
{
switch (event) {
case EVENT_COMMIT:
HidePanel(panelHandle);
DiscardPanel(panelHandle);
QuitUserInterface(0);
break;
}
return 0;
}
int CVICALLBACK LightSwitchCallback (int panel int control int event
void *callbackData int eventData1 int eventData2)
{
switch (event) {
case EVENT_COMMIT:
GetCtrlVal (panelHandle PANEL_BINARYSWITCH &lightVal);
SetCtrlVal (panelHandle PANEL_LED lightVal);
break;
}
return 0;
}
long int DLLEXPORT __stdcall MyDLLStdcallFunction(LPSTR buffer)
{
MessageBox(NULL buffer “DLL MessageBox called from MyDLLStdcallFunction“ MB_OK);
status = 200;
return (status);
}
long int DLLEXPORT MyDLLCdeclFunction(LPSTR buffer)
{
MessageBox(NULL buffer “DLL MessageBox called from MyDLLCdeclFunction“ MB_OK);
status = 300;
return (status);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 57 2008-05-27 19:53 cvidlldemo\cvibuild.mydll\dependencies.bri
....... 928 2008-05-27 19:53 cvidlldemo\cvibuild.mydll\resources.res
....... 1127 2011-08-28 22:07 cvidlldemo\cvibuild.mydll\build.ini
....... 204 2011-08-28 22:08 cvidlldemo\cvibuild.simple\dependencies.bri
....... 298036 2011-08-28 22:08 cvidlldemo\cvibuild.simple\resources.res
....... 2868586 2011-08-28 22:08 cvidlldemo\cvibuild.simple\simple.nidobj
....... 7637 2011-08-28 22:09 cvidlldemo\cvibuild.simple\build.ini
....... 1361 2006-11-06 10:00 cvidlldemo\dlluir.h
....... 2216 2006-11-06 10:00 cvidlldemo\dlluir.uir
....... 2869 2006-11-06 10:00 cvidlldemo\mydll.c
....... 1213417 2008-05-27 19:53 cvidlldemo\mydll.cdb
....... 2684 2008-05-27 19:16 cvidlldemo\mydll.cws
....... 221184 2008-05-27 19:53 cvidlldemo\mydll.dll
....... 339 2006-11-06 10:00 cvidlldemo\mydll.h
....... 3368 2008-05-27 19:53 cvidlldemo\mydll.lib
....... 3724 2006-11-06 10:00 cvidlldemo\mydll.prj
....... 76 2006-11-06 10:00 cvidlldemo\readme.txt
....... 3890 2008-05-27 19:39 cvidlldemo\simple.c
....... 4773 2008-05-27 23:25 cvidlldemo\simple.cws
....... 3899 2008-05-27 19:32 cvidlldemo\simple.prj
....... 557056 2011-08-28 22:08 cvidlldemo\SIMPLE.exe
....... 3633568 2011-08-28 22:08 cvidlldemo\SIMPLE.cdb
....... 3207 2011-08-28 21:12 LabWindowsCVI调用DLL实用例程 .txt
目录 0 2008-05-27 23:20 cvidlldemo\cvibuild.mydll
目录 0 2008-05-27 23:25 cvidlldemo\cvibuild.simple
目录 0 2008-05-27 23:26 cvidlldemo
----------- --------- ---------- ----- ----
8834206 26
- 上一篇:完整美团饿了么外卖红包源码
- 下一篇:MediaInfo_GUI 图形化的界面
相关资源
- DotNetBar v11.8 破解版 完整dll文件
- BarTender相关dll与我的btw模版
- stellaris_icdi_nd
- NPOI2.0 dll
- msvcr100d.dll
- Reflector8 最强大的反编译工具,能一字
- 一款非常好用的.net反编译工具
- zw_DLL2LIB3破解版修复查找符号bug.zip
- 获取模块.dll文件 基址+偏移的 助手
- opencv2.0中的lib和dll,跑别人程序时可
- MaxtoCode(dll加密混淆器)
- SharpSvn.dll亲测可用
- Windows下搭建mosquitto及所需DLL文件
- NPOI_2.2全套DLL
- NPOI读写EXCEL相关dll支持xls及xlsx
- 验证码识别的OCR DLL
- 通杀UltraEdit各版本的dll替换文件
- delphi exe+bpl+Dll框架源代码和
- 编译好的libiconv.lib和libiconv.dll,含6
- crystaldecisions.crystalreports.engine.dll
- flex中调用dll,测试可用
- 用VS2015编译的hiredis.dll
- openblas vs2013 x64 库dll和lib
- NPOI Excel第三方开源dll 2.2.1和2.1.1版本
- Win 7 原版主题的三个文件和主题还原
- 查看进程、线程、DLL模块等信息
- DevComponents.DotNetBar2.dll
- msvcp120d.dll+msvcr120d.dll(x86x64)
- hadoop2.9.1 winutils.exe hadoop.dll
- 本地DLL通用验证码识别-通杀验证码
评论
共有 条评论