Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   CreateProcess() und "magnify.exe" (https://www.delphipraxis.net/172443-createprocess-und-magnify-exe.html)

Aphton 3. Jan 2013 23:37

CreateProcess() und "magnify.exe"
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallöchen,
Ich möchte per CreateProcess() die Windows Lupe starten und benützen.
Das Problem ist, dass der Inhalt der Lupe manchmal schwarz ist.
Starte ich es normal, per Explorer, funktioniert es tadellos.
Liegt höchstwahrscheinlich daran, wie ich das aufrufe. Vlt hat ja einer ne Idee =/

Relevanter Code
Delphi-Quellcode:
    if Buttons[7] then
    begin
      if not magnifyActive then
      begin
        // TODO 1: This doesnt work properly
        FillChar(magnifyProcess, SizeOf(magnifyProcess), 0);
        FillChar(StartupInfo, SizeOf(StartupInfo), 0);
        StartupInfo.cb := SizeOf(StartupInfo);
        StartupInfo.wShowWindow := SW_SHOW;
        StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
        magnifyActive := CreateProcess(pWideChar(SysDir + '\magnify.exe'),
          NIL, NIL, NIL, True, 0, NIL, NIL, StartupInfo, magnifyProcess);
      end;
    end else
      if magnifyActive then
        magnifyActive := not TerminateProcess(magnifyProcess.hProcess, 0);
Edit:
Probier habe ich bereits folgendes
.. per Shellexecute das ganze starten
.. an den Startup - Parametern rumspielen
.. ShellExecute
vergebens

Bummi 4. Jan 2013 00:08

AW: CreateProcess() und "magnify.exe"
 
kann ich leider weder

Delphi-Quellcode:
//mit
  ShellExecute(handle,'OPEN','magnify.exe',nil,nil,sw_show)
// noch mit

  ShellExecute(0,'OPEN','magnify.exe',nil,nil,sw_show)
reproduzieren ...

Aphton 4. Jan 2013 00:54

AW: CreateProcess() und "magnify.exe"
 
Probiers öfters aus.
Bei mir geschieht es auch manchmal, dass es 4-5 mal hintereinander problemlos klappt.
:S

Edit:
Hab endlich etwas gefunden

Lösung
Delphi-Quellcode:
    if Buttons[7] then
    begin
      if not magnifyActive then
      begin
        // TODO 1: This doesnt work properly
        FillChar(magnifyProcess, SizeOf(magnifyProcess), 0);
        FillChar(StartupInfo, SizeOf(StartupInfo), 0);
        StartupInfo.cb := SizeOf(StartupInfo);
        StartupInfo.wShowWindow := SW_SHOW;
        StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
        Wow64RedirectionDisabled := Wow64DisableWow64FsRedirection(Wow64Value);
        magnifyActive := CreateProcess(pWideChar(SysDir + '\magnify.exe'),
          NIL, NIL, NIL, True, 0, NIL, NIL, StartupInfo, magnifyProcess);
        if Wow64RedirectionDisabled then
          Wow64RevertWow64FsRedirection(Wow64Value);
      end;
    end else
      if magnifyActive then
        magnifyActive := not TerminateProcess(magnifyProcess.hProcess, 0);
Ich hatte es im Hinterkopf, dass es da evt. zu Problemen kommen kann, wenn man aus 32 Bit 64 Bit Anwendungen startet.. alles im Hinterkopf..
ist mir nur nicht eingefallen =/

Jedenfalls, danke für die Beteiligung

Gute Nacht


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:12 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz