Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incompatible Types: 'ShortString' and 'PAnsiChar'

Status
Not open for further replies.

vincentw56

IS-IT--Management
Oct 10, 2002
47
US
I have worked with VB for awhile and now am ready to move to Delphi. I am still fuzzy on the varibles right now. I am trying to call an external program. I have the callprocess portion working if I put the command string directly in, but when I try to use a string variable to call it, I get an error: Incompatible Types: 'ShortString' and 'PAnsiChar'. I have listed part of the code below. I am not sure what I am doing wrong or how to fix it. Any help would be appreciated. Thanks in advance.

var
SI : STARTUPINFO;
SA : SECURITY_ATTRIBUTES;
SD : SECURITY_DESCRIPTOR;
ProcInfo : PROCESS_INFORMATION;
LastError : DWORD;
ProcState : DWord;
ProcExitCode : Cardinal;
CommandLine : ShortString;
begin
FillChar(SI,SizeOf(SI),0);
with SI do
begin
cb:=SizeOf(STARTUPINFO);
cbReserved2 :=0;
lpReserved :=nil;
lpDesktop :=nil;
lpReserved2 :=nil;
end;
InitializeSecurityDescriptor(@SD,SECURITY_DESCRIPTOR_REVISION);
with SA do
begin
nLength:=SizeOf(SECURITY_ATTRIBUTES);
bInheritHandle:=False;
lpSecurityDescriptor:=@SD;
end;
CommandLine := 'c:\dvd2avi\dvd2avi.exe -ia=2 -fo=1 -cs=2 -yr=2 -tn=0 -if=['+lstFileList.Items.ValueFromIndex[0]+'] -of=[d:\demuxed.d2v] -exit';
if (not CreateProcess(nil, pchar(CommandLine), @SA, @SA, False, 0, nil, nil, SI, ProcInfo)) then

It stops at the line above when trying to compile. Thanks.

Vincent
 
I figured it out. I needed to make CommandLine an ANSIString instead of a shortstring.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top