Re: Shell or ShellExecute powercfg.cpl doesn't fire




"Ted" <2000@xxxxxxxxxx> wrote in message
news:u$Uq%23jcoFHA.1048@xxxxxxxxxxxxxxxxxxxxxxx
>> lRetVal = ShellExecute(0, "open", GS$ & "powercfg.cpl", vbNullString,
>> vbNullString, 1)
>
> Still no luck
>
> Err.LastDllError comes back 1155
> lRetVal comes back 31


A return value of 31 for ShellExecute means no association with the given
file extension. As far as I know, ShellExecute does not use SetLastError,
so the value assigned to Err.LastDllError is probably meaningless (i.e. it's
the value from an API function called before ShellExecute). Why ShellExecute
is returning 31, I don't know. I looked up its association in the Registry
and the shell command was "rundll32.exe shell32.dll,Control_RunDLL "%1",%*".

In any case, try this and see if you get any better luck:

Shell "rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl", vbNormalFocus

You should be able to use that same command line with ShellExecute, but I
really don't see any reason to do so.


--
Mike
Microsoft MVP Visual Basic


.



Relevant Pages

  • Re: calling a dos command in a program
    ... int system(const char *command); ... I've tried shellexecute but lo luck. ...
    (microsoft.public.vc.mfc)
  • Re: Create e-mail w/attachments *AND* subject/body thru own client
    ... > Private Declare Function ShellExecute Lib "shell32.dll" Alias> "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal> lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As ... > Private Sub Form_Load ...
    (microsoft.public.vb.winapi)
  • Re: Files launched w/ Followhyperlink open but not visible
    ... ByVal lpOperation As String, _ ... Dim lRet As Long, varTaskID As Variant ... 'First try ShellExecute ... stFile, vbNullString, vbNullString, lShowHow) ...
    (comp.databases.ms-access)
  • Re: Problem mit ShellExecute und LNK-Datei
    ... allen Parametern eine leere Zeichenfolge bzw. einen Pointer auf einen ... wird ein Null-Pointer übergeben und Windows interpretiert diesen Wert ... ShellExecute Me.hWnd, "Open", sLink, vbNullString, vbNullString, 1 ...
    (microsoft.public.de.vb)
  • Re: ShellExecute API
    ... I have an access database form with an image. ... Private Declare Function ShellExecute Lib "shell32.dll" Alias ... "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal ... ShellExecute 0, vbNullString, strImageName, vbNullString, ...
    (comp.databases.ms-access)