c++的乙個dll,裡面有個方法,無返回型別,乙個輸出引數(char*),兩個輸入引數。
呼叫時遇到點小問題,總結一下。
錯誤的呼叫1,直接崩潰
[dllimport("upgradeserverdll.dll")]
public
static
extern
void _upgrade_getpatchinifile(out stringbuilder lpszfilename, int b, string
c);iniaction._upgrade_getpatchinifile(
out sb, 1024 * 1000 * 1000, request["
v"].tostring());
錯誤的呼叫2,無任何資訊
[dllimport("upgradeserverdll.dll")]
public
static
extern
void _upgrade_getpatchinifile([out] string lpszfilename, int b, string
c);iniaction._upgrade_getpatchinifile(mess,
1024 * 1000 * 1000, request["
v"].tostring());
正確呼叫:
[dllimport("upgradeserverdll.dll")]
public
static
extern
void _upgrade_getpatchinifile([out] stringbuilder lpszfilename, int b, string
c); stringbuilder sb = new
stringbuilder(1024*1024);
iniaction._upgrade_getpatchinifile(sb,
1024 * 1024 , request["
v"].tostring());
C 呼叫C DLL時的編碼轉換
最近做的專案,需要在c 中呼叫c 寫的dll,因為c 預設的編碼方式是unicode,而呼叫的dll規定只處理utf8編碼格式的字串,dll中的輸入引數型別char 被我marshal成byte,輸出引數型別char 被我marshal成了string c 和c 之間的型別轉換請參閱相關資料 於是我...
ios 封裝成framework時遇到的問題
1.製作framework的時候,網上很多步驟,簡單點說就是把要封裝的類單獨拿出來建乙個工程,然後把對外公開的類推到public的檔案下。2.如果在真機上測試,那麼編譯一定是在ios deveive的狀態下commd b下編譯 3.點選products下的framework右擊在finder下找到,...
編寫C 呼叫的C DLL
最近一段時間,經常遇到這些問題,前一陣子研究了一下,沒有記下來,沒想到最近研究又有些不記得了,今天把它寫下來以備忘。一般我們提供給其他語言呼叫的dll,都是用c或者c 編寫,然後封裝。我這邊也是採用的c 首先有幾個注意點 1 如果功能很簡單,或者不使用第三方庫 如mfc自帶的庫 建立乙個win32的...