vc头文件转pas
时间:2011-12-11
来源:互联网
#define MM_PACKET_SIZE 0x20//MIN 32
#define MM_DMFC_READFLOW 0x0001
#define MM_DMFC_SETPOINT 0x0002
#define MM_DMFC_READALARM 0x0003
#define MM_DMFC_CLEARALARM 0x0004 //1
#define MM_DMFC_CONTROLMODE 0x0005 //0 digital, 1 voltage, 2 current
#define MM_DMFC_VALVEMODE 0x0006 //0 regulation 1 close 2 open
#define MM_DMFC_CLEARZERO 0x0007 //1 ClearZero
#ifndef _Compiler
#define _Compiler
#endif
#ifdef DLLLIB
#else
#define DLLLIB extern "C" _declspec(dllimport)
#pragma comment(lib,"DmfcCommonDll.lib")
#endif
DLLLIB DWORD _Compiler SendFormat(DWORD dwAddress,DWORD dwType,const char* szData,DWORD &nLen,char* szBuffer,DWORD nBufferSize);
DLLLIB BOOL _Compiler ReceiveChar(char ch);
DLLLIB VOID _Compiler GetDMFCData(char *pBuffer,DWORD size);//ASCII
DLLLIB DWORD _Compiler GetDMFCCommand();
DLLLIB CHAR DMFCData[MM_PACKET_SIZE];
DLLLIB DWORD DMFCCommand;
上面是vc的头文件,有没有高手能帮我改写成pas文件啊,我想在delphi里调用vc的dll文件,谢谢!
#define MM_DMFC_READFLOW 0x0001
#define MM_DMFC_SETPOINT 0x0002
#define MM_DMFC_READALARM 0x0003
#define MM_DMFC_CLEARALARM 0x0004 //1
#define MM_DMFC_CONTROLMODE 0x0005 //0 digital, 1 voltage, 2 current
#define MM_DMFC_VALVEMODE 0x0006 //0 regulation 1 close 2 open
#define MM_DMFC_CLEARZERO 0x0007 //1 ClearZero
#ifndef _Compiler
#define _Compiler
#endif
#ifdef DLLLIB
#else
#define DLLLIB extern "C" _declspec(dllimport)
#pragma comment(lib,"DmfcCommonDll.lib")
#endif
DLLLIB DWORD _Compiler SendFormat(DWORD dwAddress,DWORD dwType,const char* szData,DWORD &nLen,char* szBuffer,DWORD nBufferSize);
DLLLIB BOOL _Compiler ReceiveChar(char ch);
DLLLIB VOID _Compiler GetDMFCData(char *pBuffer,DWORD size);//ASCII
DLLLIB DWORD _Compiler GetDMFCCommand();
DLLLIB CHAR DMFCData[MM_PACKET_SIZE];
DLLLIB DWORD DMFCCommand;
上面是vc的头文件,有没有高手能帮我改写成pas文件啊,我想在delphi里调用vc的dll文件,谢谢!
作者: lbcdm 发布时间: 2011-12-11
他这个是静态文件,不是动态文件.DELPHI里用不了的
作者: jzy_QQ_396638838 发布时间: 2011-12-11
我本身就有这两个文件DmfcCommonDll.dll和DmfcCommonDll.lib
然后我自己改了一下:
// H to Pas Converter Ver.1.20.1.47 by K.Kumaki
// Date : 10 Dec 2011
// Source : Dmfc.h (25 Aug 2008)
unit Dmfc;
{$X+}{$Z2}{$A8}
interface
uses Windows;
const
MM_PACKET_SIZE = $20; //MIN 32
MM_DMFC_READFLOW = $0001;
MM_DMFC_SETPOINT = $0002;
MM_DMFC_READALARM = $0003;
MM_DMFC_CLEARALARM = $0004; //1
MM_DMFC_CONTROLMODE = $0005; //0 digital, 1 voltage, 2 current
MM_DMFC_VALVEMODE = $0006; //0 regulation 1 close 2 open
MM_DMFC_CLEARZERO = $0007; //1 ClearZero
function SendFormat(dwAddress: LongInt; dwType: LongInt; const szData: PChar; nLen: DWORD ; szBuffer: Byte ; nBufferSize:DWORD ): Double;stdcall;external 'DmfcCommonDll.dll'
function ReceiveChar(ch: char): Double;stdcall;external 'DmfcCommonDll.dll'
function GetDMFCData(pBuffer: PChar; size: DWORD): Double;stdcall;external 'DmfcCommonDll.dll' //ASCII
function GetDMFCCommand: Double;stdcall;external 'DmfcCommonDll.dll'
//var
// CHAR : DLLLIB;
//DMFCData : array[0..MM_PACKET_SIZE-1] of DLLLIB;
//DWORD, DMFCCommand : DLLLIB;
//For Example Sending part
(*
char szCommand[MM_PACKET_SIZE];
DWORD nLen;
DWORD nErrorCode=SendFormat(32,MM_DMFC_CLEARALARM,"1",nLen,szCommand,MM_PACKET_SIZE);
//if reading,"SendFormat(32,MM_DMFC_READALARM,NULL,nLen,szCommand,MM_PACKET_SIZE);"
if(!nErrorCode)
{
//nErrorCode=0 is successful.
//you just need to make like sendToCom(szCommand,nLen) function
}
else
{
//failed.
}
*)
//For Example Receiving part
(*
char szCommand[]=your COM buffer;
DWORD nLen=your size of COM buffer;
for(DWORD i=0;i<nLen;i++)
if( ReceiveChar(szCommand[i]) )
{
//if it is true,processing the data.
//DMFCCommand meaning the number of Command
//DMFCData[] meaning the data of finished command
}
*)
implementation
end.
在delphi里已能调用,所以我现在就有点糊涂了,像我这样写的话,是不是可以,请高手批评指正!谢谢!
然后我自己改了一下:
// H to Pas Converter Ver.1.20.1.47 by K.Kumaki
// Date : 10 Dec 2011
// Source : Dmfc.h (25 Aug 2008)
unit Dmfc;
{$X+}{$Z2}{$A8}
interface
uses Windows;
const
MM_PACKET_SIZE = $20; //MIN 32
MM_DMFC_READFLOW = $0001;
MM_DMFC_SETPOINT = $0002;
MM_DMFC_READALARM = $0003;
MM_DMFC_CLEARALARM = $0004; //1
MM_DMFC_CONTROLMODE = $0005; //0 digital, 1 voltage, 2 current
MM_DMFC_VALVEMODE = $0006; //0 regulation 1 close 2 open
MM_DMFC_CLEARZERO = $0007; //1 ClearZero
function SendFormat(dwAddress: LongInt; dwType: LongInt; const szData: PChar; nLen: DWORD ; szBuffer: Byte ; nBufferSize:DWORD ): Double;stdcall;external 'DmfcCommonDll.dll'
function ReceiveChar(ch: char): Double;stdcall;external 'DmfcCommonDll.dll'
function GetDMFCData(pBuffer: PChar; size: DWORD): Double;stdcall;external 'DmfcCommonDll.dll' //ASCII
function GetDMFCCommand: Double;stdcall;external 'DmfcCommonDll.dll'
//var
// CHAR : DLLLIB;
//DMFCData : array[0..MM_PACKET_SIZE-1] of DLLLIB;
//DWORD, DMFCCommand : DLLLIB;
//For Example Sending part
(*
char szCommand[MM_PACKET_SIZE];
DWORD nLen;
DWORD nErrorCode=SendFormat(32,MM_DMFC_CLEARALARM,"1",nLen,szCommand,MM_PACKET_SIZE);
//if reading,"SendFormat(32,MM_DMFC_READALARM,NULL,nLen,szCommand,MM_PACKET_SIZE);"
if(!nErrorCode)
{
//nErrorCode=0 is successful.
//you just need to make like sendToCom(szCommand,nLen) function
}
else
{
//failed.
}
*)
//For Example Receiving part
(*
char szCommand[]=your COM buffer;
DWORD nLen=your size of COM buffer;
for(DWORD i=0;i<nLen;i++)
if( ReceiveChar(szCommand[i]) )
{
//if it is true,processing the data.
//DMFCCommand meaning the number of Command
//DMFCData[] meaning the data of finished command
}
*)
implementation
end.
在delphi里已能调用,所以我现在就有点糊涂了,像我这样写的话,是不是可以,请高手批评指正!谢谢!
作者: lbcdm 发布时间: 2011-12-11
还有个情况请高手赐教,既然这个头文件中说的是静态库(DmfcCommonDll.lib),我用vc++给重新发布后,还要提示要把动态库(DmfcCommonDll.dll)拷到应用程序同一目录,否则程序无法运行!谢谢!
作者: lbcdm 发布时间: 2011-12-11
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28