msc.dll中的函式原型為:MSPAPI const char* QTTSSessionBegin(const char* params, int* errorCode)
用法示例(其中的MSP_SUCCESS為數字0):
const char* params= “ssm=1, ent=intp65, aue=speex-wb;7,auf=audio/L16;rate=16000”;
int ret = MSP_SUCCESS;
const char* session_id = QTTSSessionBegin( params, &ret );
if(MSP_SUCCESS != ret )
{
printf( “QTTSSessionBegin failed, error code is: %d”, ret );
}
請大家看看我轉成delphi的代碼哪里有問題,先謝謝大家了!
function QTTSSessionBegin(Params: PChar; ErrorCode: PInteger):string; stdcall; external 'msc.dll';
procedure TForm1.Button1Click(Sender: TObject);
var
SessionStr, SessionID: string;
r: PInteger;
a: Integer;
begin
a := 0;
r := @a;
SessionStr := 'ssm=1, ent=intp65, aue=speex-wb;7, auf=audio/L16;rate=16000';
SessionID := QTTSSessionBegin(PChar(SessionStr), r);
ShowMessage(SessionID);
end;
點擊Button1執行到呼叫QTTSSessionBegin就報錯:Access violation at address ...... in module 'msc.dll'. Write of address ......
uj5u.com熱心網友回復:
PChar改為PAnsiCharuj5u.com熱心網友回復:
把 stdcall 改為 cdecl 試試。可參考:
http://blog.csdn.net/huang_xw/article/details/7524359
uj5u.com熱心網友回復:
都不是這些原因,提問前我就試過了,還是謝謝你們!還有沒有高手來幫我看看是啥問題?
uj5u.com熱心網友回復:
呼叫其它語言的DLL,最好不用string,用pchar或pansicharfunction QTTSSessionBegin(Params: PChar; ErrorCode: PInteger):pchar; stdcall; external 'msc.dll';
uj5u.com熱心網友回復:
以前用過訊飛的Delphi版的DLL,不過需要安裝N多的軟體才能用,現在基本上都是C的DLL了。uj5u.com熱心網友回復:
SessionStr:string改成SessionStr:array[0..255] of charuj5u.com熱心網友回復:
問題依舊,大俠來幫幫忙吧。uj5u.com熱心網友回復:
ErrorCode: PInteger 改成var errorCode: integerQTTSSessionBegin(PChar(SessionStr), r)改成QTTSSessionBegin(PChar(SessionStr), a)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/82129.html
標籤:語言基礎/算法/系統設計
上一篇:XE5呼叫DLL問題
