Delphi code. I readed http://ghisler.ch/wiki/index.php/TCUtils.cpp and try
to do this with code below. Memo shows Text ok. But TC do not recognize
my command. I readed http://www.ghisler.ch/board/viewtopic.php?t=24865
also but tips given there do not help. MVV wrote there how to add chars to
a parameter, but I can not use #0 in Delphi because it breaks string and if
even I use it the command do not work. How to do this correctly in Delphi?
Please tell me how to fix my code. Is only way to change dirs id using a CD
command added in own em_ commands? I gues no because method with a
similar code in C was given in topic from link above so it work somehow ;/
Code: Select all
private
procedure WMCopyData(var Msg : TWMCopyData); message WM_COPYDATA;
public
end;
var
Form1 : TForm1;
implementation
{$R *.dfm}
procedure TForm1.WMCopyData(var Msg : TWMCopyData);
var
S : string;
begin
S := PChar(Msg.CopyDataStruct.lpData);
Memo1.Lines.Add(S);
Msg.Result := 2006;
end;
procedure SendChangeDirectory(FirstPath, SecondPath, Flags : string);
var
Tc_H : HWND;
WholePath : string;
DataStruct : CopyDataStruct;
begin
TC_H := FindWindow('TTOTAL_CMD', nil);
if (TC_H <> 0) then
begin
if (FirstPath = '') then
begin
Exit;
end
else
begin
WholePath := FirstPath + #10;
if (SecondPath <> '') then
begin
WholePath := WholePath + SecondPath;
end;
if (Flags <> '') then
begin
WholePath := WholePath + Flags;
end;
DataStruct.dwData := Ord('C') + 256 * Ord('D');
DataStruct.cbData := Length(WholePath) + 1;
DataStruct.lpData := PChar(WholePath);
SendMessage(TC_H, WM_COPYDATA, 0, Integer(@DataStruct));
SendMessage(Form1.Handle, WM_COPYDATA, 0, Integer(@DataStruct));
SetForegroundWindow(TC_H);
end;
end;
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
SendChangeDirectory('C:\', '' , '');
end;