Hallo Achim,
ich habe von einem Bekannten einmal eine solche Funktion bekommen, die
ich Dir gerne weitergebe.
Sub WindowsGoHome()
#if TargetWin32 then
Const TOKEN_ADJUST_PRIVILEGES = 32
Const TOKEN_QUERY = 8
Const SE_PRIVILEGE_ENABLED = 2
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Const EWX_POWEROFF = 8
Dim Dummy As integer
Dim hdlProcessHandle As Integer
Dim hdlTokenHandle As MemoryBlock
Dim hdlTokenH As Integer
Dim lBufferNeeded As MemoryBlock
Dim tkp As MemoryBlock
Dim tkpNewButIgnored As MemoryBlock
Dim TmpLUID As MemoryBlock
Dim SysName As MemoryBlock
Dim Name As MemoryBlock
Dim Erg As Integer
SysName=newMemoryBlock(256)
Name=newMemoryBlock(256)
hdlTokenHandle=newMemoryBlock(4)
lBufferNeeded=newMemoryBlock(4)
SysName.CString(0)=""+chr(0)
Name.CString(0)="SeShutdownPrivilege"+chr(0)
tkp=newMemoryBlock(16)
tkpNewButIgnored=newMemoryBlock(16)
TmpLUID=newMemoryBlock(12)
Declare Function GetCurrentProcess Lib "kernel32.dll" () As integer
Declare Function OpenProcessToken Lib "advapi32.dll" ( ByVal
ProcessHandle As integer, ByVal DesiredAccess As integer, TokenHandle
As Ptr) As integer
Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias
"LookupPrivilegeValueA" ( lpSystemName As Ptr, lpName As Ptr, lpLuid As
Ptr) As integer
Declare Function AdjustTokenPrivileges Lib "advapi32.dll" ( ByVal
TokenHandle As Integer, ByVal DisableAllPrivileges As integer, NewState
As Ptr, ByVal BufferLength As Integer, PreviousState As Ptr,
ReturnLength As Ptr) As integer
Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As
integer, ByVal dwReserved As integer) As integer
hdlProcessHandle=GetCurrentProcess()
//msgBox "Prozesshandle: "+str(hdlProcessHandle)
Dummy=Bitwise.Bitor(TOKEN_ADJUST_PRIVILEGES,TOKEN_QUERY)
Dummy=OpenProcessToken(hdlProcessHandle,Dummy,hdlTokenHandle)
//msgBox "Prozess geöffnet: (<>0)"+str(Dummy)
Erg=LookupPrivilegeValue(SysName,Name,TmpLUID)
//msgBox "Privileg setzen: (<>0)"+str(Erg)
TmpLUID.Long(8)=SE_PRIVILEGE_ENABLED
tkp.Long(0)=1
tkp.Long(4)=TmpLUID.Long(0)
tkp.Long(8)=TmpLUID.Long(4)
tkp.Long(12)=TmpLUID.Long(8)
hdlTokenH=hdlTokenHandle.Long(0)
Erg=AdjustTokenPrivileges(hdlTokenH,0,tkp,16,tkpNewButIgnored,lBufferNee
ded)
//msgBox "Ich darf jetzt runterfahren: (<>0)"+str(Erg)
Erg=ExitWindowsEx(Bitwise.Bitor(Bitwise.Bitor(EWX_SHUTDOWN,EWX_POWEROFF)
,EWX_FORCE),0)
//msgBox "Kill alle Prozesse und Schluss: (<>0)"+str(Erg)
//msgBox "und Tschüss!"
#endif
End Sub
Gruß
Rudi
Am 10.04.2006 um 07:26 schrieb Achim Kredteck:
...vielleicht hat ja jemand noch einen Codeschnipsel irgendwo ??
Danke und schönen Tag noch
Achim
From 10 Apr 2006 10:38 GMT
Return-Path: <realbasic-nug dot de-bounces at lists dot realsoftware dot com>
Received: from lists.realsoftware.com (209.198.132.125) by realsoftware.com
with ESMTP (Eudora Internet Mail Server 3.1.3);
Mon, 10 Apr 2006 05:36:25 -0500
Received: from lists.realsoftware.com (localhost [127.0.0.1])
by lists.realsoftware.com (Postfix) with ESMTP
id C39A611D22F2; Mon, 10 Apr 2006 05:36:21 -0500 (CDT)
X-Original-To: realbasic-nug dot de at lists dot realsoftware dot com
Delivered-To: realbasic-nug dot de at lists dot realsoftware dot com
Received: from mailout03.sul.t-online.com (mailout03.sul.t-online.com
[194.25.134.81])
by lists.realsoftware.com (Postfix) with ESMTP id 85F6511D22E0
for <realbasic-nug dot de at lists dot realsoftware dot com>;
Mon, 10 Apr 2006 05:36:18 -0500 (CDT)
Received: from fwd29.aul.t-online.de by mailout03.sul.t-online.com with smtp
id 1FStkn-0005dw-0A; Mon, 10 Apr 2006 12:36:17 +0200
Received: from 192.168.2.14
(ZZtAoZZUweMyu1v2ajtE+UUEkSpSp7dlBi8vXIig+PdTYTnXD+d-Ed at [80 dot 139
dot 219 dot 216])
by fwd29.sul.t-online.de
with smtp id 1FStkg-1kZqIi0; Mon, 10 Apr 2006 12:36:10 +0200
MIME-Version: 1.0
From: mm-systems at t-online dot de (Achim Kredteck)
To: "REALbasic NUG German" <realbasic-nug dot de at lists dot realsoftware dot
com>
X-Mailer: T-Online eMail 5.00.0035
Content-Type: Text/Plain;
Charset="ISO-8859-1"
Content-Transfer-Encoding: Quoted-Printable
Date: 10 Apr 2006 10:38 GMT
Message-ID: <1FStkg-1kZqIi0 at fwd29 dot sul dot t-online dot de>
X-ID: ZZtAoZZUweMyu1v2ajtE+UUEkSpSp7dlBi8vXIig+PdTYTnXD+d-Ed
X-TOI-MSGID: 99946911-45d2-4fa1-8a4c-20c88d1f858a
Subject: Re: PowerOff
X-BeenThere: realbasic-nug dot de at lists dot realsoftware dot com
X-Mailman-Version: 2.1.2
Precedence: list
Reply-To: REALbasic NUG German <realbasic-nug dot de at lists dot realsoftware dot
com>
Sender: realbasic-nug dot de-bounces at lists dot realsoftware dot com
Errors-To: realbasic-nug dot de-bounces at lists dot realsoftware dot com
Hallo Rudi!
Also, meinen herzlichen Dank, der Code funktioniert auf Anhieb!
Danke........
Ich war zwar auf dem richtigen Weg, aber das hätte wohl noch Tage gedauert, bis ich wenn überhaupt soweit gekommen wäre.
Wirklich nett von Dir...
Schönen Tag noch
Achim
From Mon 10 Apr 2006 15:44:26 +0200
Return-Path: <realbasic-nug dot de-bounces at lists dot realsoftware dot com>
Received: from lists.realsoftware.com (209.198.132.125) by realsoftware.com
with ESMTP (Eudora Internet Mail Server 3.1.3);
Mon, 10 Apr 2006 08:44:37 -0500
Received: from lists.realsoftware.com (localhost [127.0.0.1])
by lists.realsoftware.com (Postfix) with ESMTP
id 5E2B111D28EB; Mon, 10 Apr 2006 08:44:34 -0500 (CDT)
X-Original-To: realbasic-nug dot de at lists dot realsoftware dot com
Delivered-To: realbasic-nug dot de at lists dot realsoftware dot com
Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de
[80.67.18.13])
by lists.realsoftware.com (Postfix) with ESMTP id E464711D28DF
for <realbasic-nug dot de at lists dot realsoftware dot com>;
Mon, 10 Apr 2006 08:44:30 -0500 (CDT)
Received: (qmail 12888 invoked from network); 10 Apr 2006 13:44:26 -0000
Received: from unknown (HELO [192.168.1.80]) (363246 at [84 dot 175 dot 96 dot
136])
(envelope-sender <support at monkeybreadsoftware dot de>)
by smtprelay01.ispgateway.de (qmail-ldap-1.03) with SMTP
for <realbasic-nug dot de at lists dot realsoftware dot com>;
10 Apr 2006 13:44:26 -0000
To: realbasic-nug dot de at lists dot realsoftware dot com (REALbasic NUG
German)
In-Reply-To: <3227327954 dot 1202274314815 at [192 dot 168 dot 178 dot 41]>
From: support at monkeybreadsoftware dot de (Christian Schmitz)
Date: Mon, 10 Apr 2006 15:44:26 +0200
Message-ID: <1hdl514 dot 7v8qfnpja627M%support at monkeybreadsoftware dot de>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Organization: Monkeybread Software Germany
X-Face: nrf3>{WQ6c&r+7 at e)"]0G60`-6ND^)I2mI%>)QGYa=9"=7jhd-g2|b3!>Al0+
Ccb%xGQshhi|g at QU2$
User-Agent: MacSOUP/D-2.7 (Mac OS X version 10.4.5)
Subject: Re: Datei mit vorgegebenem Programm =?iso-8859-1?q?öffnen?X-BeenThere:
realbasic-nug dot de at lists dot realsoftware dot com
X-Mailman-Version: 2.1.2
Precedence: list
Reply-To: REALbasic NUG German <realbasic-nug dot de at lists dot realsoftware dot
com>
Sender: realbasic-nug dot de-bounces at lists dot realsoftware dot com
Errors-To: realbasic-nug dot de-bounces at lists dot realsoftware dot com
Stefan Mettenbrink <S dot Metti at gmx dot de> wrote:
Ich kann mit f.launch eine Datei mit dem Standardprogramm öffnen. Kann
ich auch ein Programm starten und diesem die Datei zu öffnen
übergeben?
Wenn ja, wie?
Für Mac OS X: LaunchService Funktionen im Plugin.
Für Windows: Shell mit "Programmpfad Dokumentenpfad" als Befehl.
Gruß
Christian
--
Around eleven thousand functions in one REALbasic plug-in.
The Monkeybread Software Realbasic Plugin v6.1.
<http://www.monkeybreadsoftware.de/realbasic/plugins.shtml>
|