Amnon82
8th April 2006, 23:36
http://img138.imageshack.us/img138/3493/d2vc0012mq.png
There was alway the problem, that we don't get the d2v infos in text. Until DGIndex 1.47 comes out, having this feature, you can use D2VCreate + DGIndex 1.46 to get it also in TXT.
_________________________________________________________
Version 0.01
* public release
* Download 0.01 + Source (http://home.arcor.de/autoq2_amsoft/files/delphi/source/D2VCreate_0.01_withsource.zip)
Amnon82
9th April 2006, 22:44
{=== EnumChildWindowsProc ==========================================
This function copies the DGIndex text to string
{===================================================================}
function EnumChildWindowsProc(Wnd: HWnd; Lista: TList): Bool; export;
{$ifdef Win32} stdcall; {$endif}
var
BufferText: array[0..99] of Char;
CtrlId : integer;
Elemento : PVentana;
begin
GetWindowText(Wnd, BufferText, 100);
if StrPas(BufferText) = '' then BufferText := 'Empty';
CtrlId := GetDlgCtrlId(Wnd);
New(Elemento);
Elemento^.CtrlHwnd := wnd;
Elemento^.CtrlId := CtrlId;
StrCopy(Elemento^.Text,BufferText);
Lista.Add(Elemento);
if GetWindow(Wnd, GW_CHILD) = 0 then
Enumchildwindows(Wnd, @EnumChildWindowsProc, 0);
Result := True;
end;
{===================================================================}
{=== CreatedD2V ====================================================
This function checks if the D2V file was created
{===================================================================}
function CreatedD2v(): boolean;
var
f: file of Byte;
OldFileMode: Byte;
D2VSize : LongInt;
begin
olDFileMode := FileMode;
AssignFile(f, D2VFILENAME+'.d2v');
FileMode := 0; {Set file access to read only }
Reset(f);
D2VSize := FileSize(f);
CloseFile(f);
FileMode := OldFileMode;
if D2vFileSize < D2VSize then Result := False
else
begin
if StopPlayDgIndexTimer=0 then Form1.PlayDGIndex.enabled:=true;
end;
if PlayDGIndexTimerResult=1 then
begin
Result := True;
informationHwnd := FindWindow(nil,'Information');
EnumChildWindows(informationHwnd, @EnumChildWindowsProc, LParam(MiLista));
PostMessage(GetParent(InformationHwnd),WM_KEYDOWN,VK_F5,0);
Sleep(5000);
PostMessage(GetParent(InformationHwnd),WM_KEYDOWN,VK_ESCAPE,0);
informationHwnd := FindWindow(nil,'Information');
EnumChildWindows(informationHwnd, @EnumChildWindowsProc, Lparam(MiLista2));
end;
D2vFileSize := D2VSize;
end;
{===================================================================}
{=== GetProcessID + KillProcess ====================================
With this we kill the DGIndex.task
{===================================================================}
function GetProcessID(sProcName: String): Integer;
var
hProcSnap: THandle;
pe32: TProcessEntry32;
begin
result := -1;
hProcSnap := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
if hProcSnap = INVALID_HANDLE_VALUE then exit;
pe32.dwSize := SizeOf(ProcessEntry32);
if Process32First(hProcSnap, pe32) = true then
while Process32Next(hProcSnap, pe32) = true do
begin
if pos(sProcName, pe32.szExeFile) <> 0then
result := pe32.th32ProcessID;
end;
CloseHandle(hProcSnap);
end;
procedure KillProcess(dwProcID: DWORD);
var
hProcess : Cardinal;
dw : DWORD;
begin
hProcess := OpenProcess(SYNCHRONIZE or PROCESS_TERMINATE, False, dwProcID);
TerminateProcess(hProcess, 0);
dw := WaitForSingleObject(hProcess, 5000);
case dw of
WAIT_TIMEOUT:
begin
CloseHandle(hProcess);
exit;
end;
WAIT_FAILED:
begin
if process='cceokfix.exe' then form3.log.lines.add(TimeToStr(time)+' - '+DateToStr(Date)+' >> '+pchar('ERROR: Can''t kill Process: '+process+#10#13+'Please check if you have placed the '''+process+''''+#10#13+'in: '''+ExtractFilePath(ParamStr(0))+''''))
else
if process='cceokfix.exe' then form3.log.lines.add(TimeToStr(time)+' - '+DateToStr(Date)+' >> '+pchar('ERROR: Can''t kill Process: '+process+#10#13+'Please check if you have placed the '''+process+''''+#10#13+'in: '''+ccepath));
CloseHandle(hProcess);
exit;
end;
end;
CloseHandle(hProcess);
end;
{===================================================================}
{=== RunAndWaitShell ===============================================
This is a extended Version of Shellexecute. It will wait untill
the process is done.
{===================================================================}
procedure RunAndWaitShell(Executable, Parameter: STRING; ShowParameter: INTEGER; WaitParameter:Integer; D2VCreatedParameter:Integer);
var
Info: TShellExecuteInfo;
pInfo: PShellExecuteInfo;
exitCode: DWord;
begin
pInfo := @Info;
with Info do
begin
cbSize := SizeOf(Info);
fMask := SEE_MASK_NOCLOSEPROCESS;
wnd := application.Handle;
lpVerb := NIL;
lpFile := PChar(Executable);
lpParameters := PChar(Parameter + #0);
lpDirectory := NIL;
nShow := ShowParameter;
hInstApp := 0;
end;
ShellExecuteEx(pInfo);
if D2VcreatedParameter=1 then
repeat
exitCode := WaitForSingleObject(Info.hProcess, WaitParameter);
Application.ProcessMessages;
until
((exitCode <> WAIT_TIMEOUT ) or (CreatedD2v() = true))
else
repeat
exitCode := WaitForSingleObject(Info.hProcess, WaitParameter);
Application.ProcessMessages;
until
(exitCode <> WAIT_TIMEOUT);
end;
{===================================================================}
{=== PlayDGIndexTimer ==============================================}
procedure TForm1.PlayDGIndexTimer(Sender: TObject);
var
f: file of Byte;
OldFileMode: Byte;
D2VSize : LongInt;
begin
PlayDGIndex.Enabled:=false;
if PlayDGIndexTimerResult=1 then exit;
olDFileMode := FileMode;
AssignFile(f, D2VFILENAME+'.d2v');
FileMode := 0; {Set file access to read only }
Reset(f);
D2VSize := FileSize(f);
CloseFile(f);
FileMode := OldFileMode;
if D2vFileSize2 < D2VSize then
begin
//form1.memo1.lines.add(TimeToStr(time)+' - '+DateToStr(Date)+' >> Timer call');
D2vFilesize2:=D2vSize;
exit;
end
else
begin
//form1.memo1.lines.add(TimeToStr(time)+' - '+DateToStr(Date)+' >> Timer execute');
StopPlayDgIndexTimer:=1;
PlayDGIndexTimerResult:=1;
end;
end;
{===================================================================}
I added a timer and my own modified RunAndWaitShell, so you can move the form during the filechecks.
How it works, take a look on AutoQ2 1152 :D
Amnon82
14th April 2006, 10:29
D2V Create 0.03 you can find in the newest AutoQ2 build :D
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.