![]() |
Shellexeute startet Win8 app nicht
Hallo,
ich betreibe eine Win32-Anwendung (Delphi XE2) auf einem Tablet-PC mit Windows 8 Pro. Aus der Delphi-Anwendung möchte ich einige Win8-apps starten (z.B. Kamera = C:\Windows\Camera\Camera.exe). Leider funktioniert der Winapi-Aufruf "Shellexecute" nicht. Die Kamera-App (camera.exe) kann auch nicht per Doppelklick aus dem Windows Explorer gestartet werden, sondern nur aus der Metro-Oberfläche klappt das. Der Delphi Programmcode: // sollte die Kamera-App unter Win8 starten procedure TForm1.bt_KameraClick(Sender: TObject); var rslt : integer; begin rslt := ShellExecute_woWait ('C:\Windows\Camera\Camera.exe',''); end; // Winapi-Aufruf: function ShellExecute_woWait(FileName: string; Params: string):integer; var exepath:string; begin Result := 0; if (not FileExists(FileName)) then begin Result := ERROR_FILE_NOT_FOUND; exit; end; exepath := extractFilepath(FileName); Result := ShellExecute(0, // handle to parent window nil, // pointer to string that specifies operation to perform (--> klappt auch nicht mit 'open') PChar(FileName), // pointer to filename string PChar(Params), // pointer to string that specifies executable-file parameters PChar(exepath), // pointer to string that specifies default directory (--> klappt auch nicht mit nil) SW_SHOWNORMAL // whether file is shown when opened ); // >32: erfolgreich if Result>32 then Result := 0; end; Wie kann ich aus einer Win32-Anwendung eine Win8 app starten? Danke. Punki:) |
AW: Shellexeute startet Win8 app nicht
Welchen Fehler gibt ShellExecute denn zurück bzw. was sagt GetLastError?
|
AW: Shellexeute startet Win8 app nicht
Zitat:
Das Problem ist, dass eine App nur mit einer entsprechenden Umgebung (in einem App-Container) gestartet werden kann. Wie man das aus einer Desktop-Anwendung heraus machen kann, weiß ich aber auch nicht. |
AW: Shellexeute startet Win8 app nicht
Ich habe da mal einen Artikel aufgetrieben:
![]() Dort wird automatisches Testen beschrieben. Ein Teil davon ist es, die Win8 App aufzurufen. Im wesentlichen muss man wohl das ![]() C# Code gibt es wohl hier: ![]() |
AW: Shellexeute startet Win8 app nicht
Danke für die Hinweise,
ich habe inzwischen eine Lösung mit Powershell gefunden: ![]() Ich starte damit von meinem Delphi-prog die Camera-app unter Win8 mit Shellexecute. rslt := ShellExecute_woWait ('C:\Windows\System32\WindowsPowerShell\v1.0\power shell.exe' , 'Camera.ps1', SW_SHOWMINIMIZED) //----------------------------------- Camera.ps1: $code = @" using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace Win8 { public enum ActivateOptions { None = 0x00000000, // No flags set DesignMode = 0x00000001, // The application is being activated for design mode, and thus will not be able to // to create an immersive window. Window creation must be done by design tools which // load the necessary components by communicating with a designer-specified service on // the site chain established on the activation manager. The splash screen normally // shown when an application is activated will also not appear. Most activations // will not use this flag. NoErrorUI = 0x00000002, // Do not show an error dialog if the app fails to activate. NoSplashScreen = 0x00000004, // Do not show the splash screen when activating the app. } [ComImport, Guid("2e941141-7f97-4756-ba1d-9decde894a3d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown )] interface IApplicationActivationManager { // Activates the specified immersive application for the "Launch" contract, passing the provided arguments // string into the application. Callers can obtain the process Id of the application instance fulfilling this contract. IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId); IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] String verb, [Out] out UInt32 processId); IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out UInt32 processId); } [ComImport, Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]//Application Activation Manager public class ApplicationActivationManager : IApplicationActivationManager { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)/*, PreserveSig*/] public extern IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] public extern IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] String verb, [Out] out UInt32 processId); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] public extern IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out UInt32 processId); } } "@ add-type -TypeDefinition $code $appman = new-object Win8.ApplicationActivationManager function Get-MetroApp { $entry = 'HKCU:\Software\Classes\ActivatableClasses\Package ' foreach ($appkey in (dir $entry |select -ExpandProperty pspath)) { #$id = ((dir (join-path $appkey 'Server')) |Get-ItemProperty).appusermodelid $id = (dir (Join-Path $appkey server) |?{$_.pspath -notmatch 'BackgroundTransferHost.1'} |Get-ItemProperty).appusermodelid if ($id) { $possibleclassidkeys = dir (join-path $appkey 'ActivatableClassID') |select -ExpandProperty pspath # we look for the app key first, then app.wwa, and then any other key if neither returns an entrypoint $key = $possibleclassidkeys |?{$_ -match 'app$'} $entrypoint=$null if ($key) { if (Test-Path (join-path $key CustomAttributes)) { $entrypoint = (Get-ItemProperty (join-path $key CustomAttributes)).('appobject.entrypoint') } } if (!$entrypoint) { $key = $possibleclassidkeys |?{$_ -match 'app.wwa$'} if ($key) { if (Test-Path (join-path $key CustomAttributes)) { $entrypoint = (Get-ItemProperty (join-path $key CustomAttributes)).('appobject.entrypoint') } } } if (!$entrypoint) { foreach ($key in $possibleclassidkeys) { if (Test-Path (join-path $key CustomAttributes)) { $entrypoint = (Get-ItemProperty (join-path $key CustomAttributes)).('appobject.entrypoint') break } } } new-object psobject -Property ([ordered] @{ EntryPoint = $entrypoint ID = $id }) } } } function Start-MetroApp { param( [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)] [string] $ID ) $appman.ActivateApplication($ID,$null,[Win8.ActivateOptions]::None,[ref]0) } Start-MetroApp Microsoft.MoCamera_cw5n1h2txyewy!Microsoft.Camera end of Camera.ps1. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz