P
pascal
Unregistered / Unconfirmed
GUEST, unregistred user!
头文件:control.h
#ifdef __BUILDING_THE_DLL
#define XPORT_TYPE __declspec(dllexport) //__export
#else
#define XPORT_TYPE __declspec(dllimport) //__import
#endif
extern XPORT_TYPE _stdcall BOOL Init(const char *Device);
extern XPORT_TYPE _stdcall void Close();
extern XPORT_TYPE _stdcall BOOL Open(const int Addr);
extern XPORT_TYPE _stdcall BOOL GetStatus(const int Addr, int *Status);
extern XPORT_TYPE _stdcall BOOL GetCount(int *Count);
DLL工程程序文件:control.cpp
#define __BUILDING_THE_DLL
#include <windows.h>
#include <assert.h>
#include "DllUnit.h"
#pragma argsused
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
extern XPORT_TYPE _stdcall BOOL Init(const char *Device)
{
//内容略
};
//其他几个函数同,略
调用工程程序orte.cpp,头文件同上
#include <vcl.h>
#include <assert.h>
#include <mem.h>
#pragma hdrstop
#include "Unit1.h"
#include "DLLUnit.h"
//---------------------------------------------------------------------------
#pragma link "CSPIN"
#pragma comment(lib, "Control.lib"
#pragma resource "*.dfm"
TForm1 *Form1;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
if (!InitComm("DEVICE1")
{
Application->MessageBox("设备占用!", "可惜", MB_OK);
Application->Terminate();
}
}
以下略;
请帮忙侃侃DLL输出/输入对没?我在C++BUILDER中静态调用运行正常,但动态调用或DELPHI不能调用DLL,老说没找到相应的函数人口?
#ifdef __BUILDING_THE_DLL
#define XPORT_TYPE __declspec(dllexport) //__export
#else
#define XPORT_TYPE __declspec(dllimport) //__import
#endif
extern XPORT_TYPE _stdcall BOOL Init(const char *Device);
extern XPORT_TYPE _stdcall void Close();
extern XPORT_TYPE _stdcall BOOL Open(const int Addr);
extern XPORT_TYPE _stdcall BOOL GetStatus(const int Addr, int *Status);
extern XPORT_TYPE _stdcall BOOL GetCount(int *Count);
DLL工程程序文件:control.cpp
#define __BUILDING_THE_DLL
#include <windows.h>
#include <assert.h>
#include "DllUnit.h"
#pragma argsused
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
extern XPORT_TYPE _stdcall BOOL Init(const char *Device)
{
//内容略
};
//其他几个函数同,略
调用工程程序orte.cpp,头文件同上
#include <vcl.h>
#include <assert.h>
#include <mem.h>
#pragma hdrstop
#include "Unit1.h"
#include "DLLUnit.h"
//---------------------------------------------------------------------------
#pragma link "CSPIN"
#pragma comment(lib, "Control.lib"
#pragma resource "*.dfm"
TForm1 *Form1;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
if (!InitComm("DEVICE1")
{
Application->MessageBox("设备占用!", "可惜", MB_OK);
Application->Terminate();
}
}
以下略;
请帮忙侃侃DLL输出/输入对没?我在C++BUILDER中静态调用运行正常,但动态调用或DELPHI不能调用DLL,老说没找到相应的函数人口?