想写个把某个具体文件夹里的dll和ocx都注册了的小程序,在一个单元中写了如下语句,代码如下:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,WinProcs;
implementation
procedure CopyAndReg(src:string);
var
srcList:TStrings;
srclength:Integer;
i:Integer;
begin
srcList:=TStringList.Create;
srcList.LoadFromFile(src);
srclength:=srcList.Count;
for i:=0 to srclength do
begin
WinExec('regsvr32 /u'+srcList(i).GetText,SW_SHOW);
WinExec('regsvr32 '+srcList(i).GetText,SW_SHOW);
end;
end;
end.
编译报错:[Error] Unit2.pas(32): Missing operator or semicolon
[Error] Unit2.pas(32): Incompatible types: 'String' and 'PAnsiChar'
请问大牛们该如何解决,是不是要把pansichar转换为string类型,本人刚刚学习delphi7
WinExec(PAnsiChar('regsvr32 /u'+srcList.strings[i]),SW_SHOW);
WinExec(PAnsiChar('regsvr32 '+srcList.strings[i]),SW_SHOW);
这样试试,还有for i:=0 to srclength-1 do,这里要减1,最后还要调用srcList.Free
WinExec(PAnsiChar('regsvr32 /u'+srcList.strings[i]),SW_SHOW);
WinExec(PAnsiChar('regsvr32 '+srcList.strings[i]),SW_SHOW);
这样试试,还有for i:=0 to srclength-1 do,这里要减1,最后还要调用srcList.Free