線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1325
推到 Plurk!
推到 Facebook!

VC的DLL轉BCB後呼叫有問題(已爬過相關文章)

答題得分者是:RaynorPao
seestyle
一般會員


發表:2
回覆:2
積分:0
註冊:2003-11-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-12-01 13:14:51 IP:202.145.xxx.xxx 未訂閱
小弟根據先進們的文章做出來所要用的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
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-12-01 13:28:59 IP:203.73.xxx.xxx 未訂閱
引言:
小弟根據先進們的文章做出來所要用的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
一般會員


發表:2
回覆:2
積分:0
註冊:2003-11-26

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-12-01 13:33:28 IP:202.145.xxx.xxx 未訂閱
RaynorPao... 很抱歉,小弟已經看過了...除了在最後我們有釋放dll的資源外...其他的應該是一樣的...但還是有問題...哇...
seestyle
一般會員


發表:2
回覆:2
積分:0
註冊:2003-11-26

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-12-01 13:51:04 IP:202.145.xxx.xxx 未訂閱
很抱歉,我再檢查過... 謝謝您的責備... 是我的不好,再次謝謝
系統時間:2024-05-05 0:10:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!