AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Shellexeute startet Win8 app nicht

Ein Thema von punki · begonnen am 10. Okt 2013 · letzter Beitrag vom 13. Okt 2013
Antwort Antwort
punki

Registriert seit: 11. Nov 2005
5 Beiträge
 
#1

Shellexeute startet Win8 app nicht

  Alt 10. Okt 2013, 18:20
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

Geändert von punki (10. Okt 2013 um 20:28 Uhr)
  Mit Zitat antworten Zitat
ringli

Registriert seit: 7. Okt 2004
504 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Shellexeute startet Win8 app nicht

  Alt 10. Okt 2013, 20:34
Welchen Fehler gibt ShellExecute denn zurück bzw. was sagt GetLastError?
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.330 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: Shellexeute startet Win8 app nicht

  Alt 10. Okt 2013, 20:58
Welchen Fehler gibt ShellExecute denn zurück bzw. was sagt GetLastError?
Was bringt das in dem Fall? Der Start ist nun einmal so nicht möglich.

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.
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
Benutzerbild von jfheins
jfheins

Registriert seit: 10. Jun 2004
Ort: Garching (TUM)
4.579 Beiträge
 
#4

AW: Shellexeute startet Win8 app nicht

  Alt 10. Okt 2013, 22:42
Ich habe da mal einen Artikel aufgetrieben: http://blogs.msdn.com/b/windowsappde...ws-8-apps.aspx
Dort wird automatisches Testen beschrieben. Ein Teil davon ist es, die Win8 App aufzurufen.
Im wesentlichen muss man wohl das Interface "IApplicationActivationManager" verwenden.

C# Code gibt es wohl hier: http://stackoverflow.com/questions/1...plication-in-c
  Mit Zitat antworten Zitat
punki

Registriert seit: 11. Nov 2005
5 Beiträge
 
#5

AW: Shellexeute startet Win8 app nicht

  Alt 13. Okt 2013, 19:20
Danke für die Hinweise,

ich habe inzwischen eine Lösung mit Powershell gefunden: http://poshcode.org/3740

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.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:44 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