什么? var returnstring:pchar; begin returnstring:='驱动器关闭错误'; pchar和string没搞清楚var mci:string; mciid:integer; begin mciid:=mcigetdeviceid(nil); mci:='setaudio '+inttostr(mciid)+ ' off'; mcisendstring(pchar(mci),0,nil,0); end;
API声明: MCIERROR mciSendString(LPCTSTR lpszCommand, LPTSTR lpszReturnString, UINT cchReturn, HANDLE hwndCallback);关于返回值的参数:lpszReturnStringAddress of a buffer that receives return information. If no return information is needed, this parameter can be NULL. cchReturnSize, in characters, of the return buffer specified by the lpszReturnString parameter. 所以在cchReturn里写返回参数的buffer大小,返回值在lpszReturnString 指针指向的内存区里,长度是cchReturn的大小
var returnstring:pchar; begin GetMem(returnstring, 128); mciSendString('set CDAudio door closed', returnstring, 127, 0); end; 或 mciSendString('set CDAudio door closed', Nil, 0, 0);
var returnstring:pchar;
begin
returnstring:='驱动器关闭错误';
pchar和string没搞清楚var
mci:string;
mciid:integer;
begin
mciid:=mcigetdeviceid(nil);
mci:='setaudio '+inttostr(mciid)+ ' off';
mcisendstring(pchar(mci),0,nil,0);
end;
MCIERROR mciSendString(LPCTSTR lpszCommand, LPTSTR lpszReturnString,
UINT cchReturn, HANDLE hwndCallback);关于返回值的参数:lpszReturnStringAddress of a buffer that receives return information. If no return information is needed, this parameter can be NULL. cchReturnSize, in characters, of the return buffer specified by the lpszReturnString parameter.
所以在cchReturn里写返回参数的buffer大小,返回值在lpszReturnString
指针指向的内存区里,长度是cchReturn的大小
begin
GetMem(returnstring, 128);
mciSendString('set CDAudio door closed', returnstring, 127, 0);
end;
或
mciSendString('set CDAudio door closed', Nil, 0, 0);