我想從VBA中獲取DLL中的整數值,如下面的代碼。如何從VBA中的DLL中獲取整數值?
double _stdcall pll_dll(double* datain0, double* datain1, double* dataout0, double* dataout1, BSTR * str, int* str_len)
{
char buff[128] = { 0 };
char * str0;
char str1[128] = { 0 };
int len;
*dataout0 = *datain0 + 20;
*dataout1 = *datain1 + 30;
len = 30;
*str_len = 30;
str0 = " Nice ";
sprintf(buff, "Hi %s \n", str0);
strcpy(str1, buff);
char* p = str1;
SysReAllocString(str, (OLECHAR*)p);
return 0;
}
VB
Private Declare PtrSafe Function pll_dll Lib "F:\work\pll_dll\x64\Debug\pll_dll.dll" _
(ByRef x_in As Double, ByRef y_in As Double, ByRef x_out As Double, ByRef y_out As Double, ByRef s As String, ByRef str_len As Integer) As Double
Dim s_len As Integer
Call pll_dll(3, 4, d1, d2, s, s_len)
但我不明白,當我跑上面的代碼,s_len總是「0'at的VBA。 但其他參數double * datain0,double * datain1,double * dataout0,double * dataout1,BSTR * str都工作正常。當我運行「double _stdcall pll_dll(double * datain0,double * datain1,double * dataout0,double * dataout1,int * str_len」)時,我擺脫了「BSTR * str」參數 )「那麼我可以得到str_len以及
你能讓我知道我應該檢查什麼嗎? 如何獲得s_len值?