seestyle
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:2 回覆:2 積分:0 註冊:2003-11-26
發送簡訊給我
|
小弟根據先進們的文章做出來所要用的code(動態連結),但在編譯當中,一值發生錯誤,訊息如下
Build
[C++ Error] gcaic.cpp(38): E2034 Cannot convert 'int (*)(int,unsigned char,int,char)' to 'int'
[C++ Error] gcaic.cpp(45): E2034 Cannot convert 'int (*)(int,unsigned char,int,char)' to 'int'
小弟的code如下:
//---------------------------------------------------------------------------
#ifndef gcaicH
#define gcaicH
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TLabel *Label1;
TLabel *Label2;
void __fastcall FormCreate(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
int iRetValue;
int iID;
unsigned char *pCard;
int iLength;
int ick;
char *sReadName;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
<.cpp部分>
#include
#pragma hdrstop
#include "gcaic.h"
#include "codeFunction.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
iID = 1;
pCard = NULL;
iLength = 0;
ick =10;
iRetValue = 0;
sReadName = NULL;
}
//---------------------------------------------------------------------------
typedef int (*GETGCA)(int,unsigned char,int,char);
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HINSTANCE dll=NULL;
GETHERE hereforce; dll=LoadLibrary("hereforce.dll");
if(dll!=NULL){
hereforce=(GETHERE)GetProcAddress(dll,"_hereforce");
if(hereforce != NULL){
iRetValue = hereforce;
if ( iRetValue !=0 ){
if (iRetValue != 4006 ){
Label2->Caption = iRetValue;}
else{
pCard = new unsigned char[iLength];
iRetValue = hereforce;}
}
if(iRetValue != 0){ick=2;}
else{ick=1;}
}
}
else{Label2->Caption = "LoadLibrary error\n";}
Label1->Caption =ick;
}
//---------------------------------------------------------------------------
#ifndef __GDCFUNCTION_DLL__
#define __GDCFUNCTION_DLL__ extern "C" __declspec(dllexport)
unsigned long __stdcall Gethereforce( int iID,unsigned char *pCard,int *pLength,char *sReaderName);
#endif
請先進們指教 發表人 - seestyle 於 2003/12/01 13:21:38 發表人 - seestyle 於 2003/12/01 13:25:28 發表人 - seestyle 於 2003/12/01 13:29:41
|
RaynorPao
版主
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](http://delphi.ktop.com.tw/download.php?download=upload/48c9d66ac5033_KTOP-%E5%8C%85%E5%AD%90%28%E7%9C%BC%E9%8F%A1%29-Q-100x100.jpg) 發表:139 回覆:3622 積分:7025 註冊:2002-08-12
發送簡訊給我
|
引言:
小弟根據先進們的文章做出來所要用的code(動態連結),但在編譯當中,一值發生錯誤,訊息如下
Build
[C Error] gcaic.cpp(38): E2034 Cannot convert 'int (*)(int,unsigned char,int,char)' to 'int'
[C Error] gcaic.cpp(45): E2034 Cannot convert 'int (*)(int,unsigned char,int,char)' to 'int'
小弟的code如下:
//---------------------------------------------------------------------------
#ifndef gcaicH
#define gcaicH
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TLabel *Label1;
TLabel *Label2;
void __fastcall FormCreate(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
int iRetValue;
int iID;
unsigned char *pCard;
int iLength;
int ick;
char *sReadName;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
<.cpp部分>
#include
#pragma hdrstop
#include "gcaic.h"
#include "codeFunction.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
iID = 1;
pCard = NULL;
iLength = 0;
ick =10;
iRetValue = 0;
sReadName = NULL;
}
//---------------------------------------------------------------------------
typedef int (*GETGCA)(int,unsigned char,int,char);
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HINSTANCE dll=NULL;
GETHERE hereforce; dll=LoadLibrary("hereforce.dll");
if(dll!=NULL){
hereforce=(GETHERE)GetProcAddress(dll,"_hereforce");
if(hereforce != NULL){
iRetValue = hereforce;
if ( iRetValue !=0 ){
if (iRetValue != 4006 ){
Label2->Caption = iRetValue;
}
else{
pCard = new unsigned char[iLength];
iRetValue = hereforce;
}
}
if(iRetValue != 0){
ick=2;
}
else{
ick=1;
}
}
}
else{
Label2->Caption = "LoadLibrary error\n";
}
Label1->Caption =ick;
}
//---------------------------------------------------------------------------
#ifndef __GDCFUNCTION_DLL__
#define __GDCFUNCTION_DLL__ extern "C" __declspec(dllexport)
unsigned long __stdcall Gethereforce( int iID,unsigned char *pCard,int *pLength,char *sReaderName);
#endif
請先進們指教
seestyle 你好:
(1)請問?? 這篇文章看過了嗎??
>
( >
>> --
------ -- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
|
seestyle
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:2 回覆:2 積分:0 註冊:2003-11-26
發送簡訊給我
|
RaynorPao...
很抱歉,小弟已經看過了...除了在最後我們有釋放dll的資源外...其他的應該是一樣的...但還是有問題...哇...
|
seestyle
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:2 回覆:2 積分:0 註冊:2003-11-26
發送簡訊給我
|
很抱歉,我再檢查過...
謝謝您的責備...
是我的不好,再次謝謝
|