各位大俠小弟用vc沒有几天﹐但是這次項目必須要用vc去寫。
主要是用vc寫個dll然后要到vb中調用。但是我從沒有用vc寫過dll。我現在只想快速入門。因為沒有太多的時間去翻資料找到寫dll的方法。
希望大俠們有空指點小弟一二。
class shipclass
{
private:
double dbnumbers ,dbweights,dbcubages;
public: string strtrackingnumber,strmaxicode,strzipcode;
shipclass shipmethod(){}
};
我想把這個類封裝到dll中
然后在vb中調用它。
能不能實現﹐如果能的話﹐該如何去封裝到dll中。操作方法越詳細越好。
我會高分回報。
小弟在線等﹐很急。
主要是用vc寫個dll然后要到vb中調用。但是我從沒有用vc寫過dll。我現在只想快速入門。因為沒有太多的時間去翻資料找到寫dll的方法。
希望大俠們有空指點小弟一二。
class shipclass
{
private:
double dbnumbers ,dbweights,dbcubages;
public: string strtrackingnumber,strmaxicode,strzipcode;
shipclass shipmethod(){}
};
我想把這個類封裝到dll中
然后在vb中調用它。
能不能實現﹐如果能的話﹐該如何去封裝到dll中。操作方法越詳細越好。
我會高分回報。
小弟在線等﹐很急。
我還不能解決如何調用如下的函數
class csshipdata
{
public:
string strtrackingnumber;
string strmaxicode;
string strzipcode;
};
csshipdata getshipinfo()
{
}
我在test.cpp中定義
extern "C" string APIENTRY csshipmethod(double numbers);
extern "C" string APIENTRY csshipmethod(double numbers)
{
return "ok";
}
編譯都不能通過。
class __declspec( dllexport ) csshipdata
{
}
将整个类导出。
二按照下面的方法定义你的类
class AFX_EXT_CLASS shipclass
{
private:
double dbnumbers ,dbweights,dbcubages;
public: string strtrackingnumber,strmaxicode,strzipcode;
shipclass shipmethod(){}
};
三把需要引用的lib和h文件放到使用这个类的工程中,然后把编译生成的dll
放到执行程序的同一个目录下就行了。
不难,试试吧
但現在還不想結貼。
我在dll中定義了下面的函數
LPSTR FAR PASCAL _export csshipmethod(double numbers)
{
return "ok";
}
在vb中我這樣調用
Private Declare Function csshipmethod Lib "test.dll" (ByVal numbers As Double) As String
Private Sub Command1_Click()
Text1.Text = csshipmethod(12)
End Sub
但text1沒有任何顯示。我想可能是LPSTR 類行在vb中不支持。可以幫忙幫我想一下嗎?