Page 1 of 1

PB5.40LTS; ShellExecute_; mailto:

Posted: Mon Oct 19, 2015 2:29 pm
by HanPBF
Hello!

Just a few days ago my program worked with

Code: Select all

ShellExecute_(#Null, "open", "mailto:adr@ress.de?body=Test", #Null, #Null, #SW_SHOWNORMAL)
But now, it does not open a mail anymore.

When I put the string "mailto:adr@ress.de?body=Test" in my browser address bar , Outllok emailis opened immediately.

I tried with giving arguments as pointers with @; no change.

Error is: "The specified file was not found" (2)

Any idea what the problem can be???

Thanks a lot in advance,
regards

Re: PB5.40LTS; ShellExecute_; mailto:

Posted: Mon Oct 19, 2015 2:38 pm
by ts-soft

Code: Select all

ShellExecute_(#Null, @"open", @"mailto:adr@ress.de?body=Test", #Null, #Null, #SW_SHOWNORMAL) 
runs without problems!

Re: PB5.40LTS; ShellExecute_; mailto:

Posted: Mon Oct 19, 2015 2:58 pm
by HanPBF
Hello tssoft

thanks for the info.

Tried it then in an empty file and it ran...

So, I must have done something to break it...

Problem is after call to this code:

Code: Select all

define Advapi32DLL = OpenLibrary(#PB_Any, "Advapi32.dll")
If Advapi32DLL
  prototype RegOverridePredefKey_Prototype(hKey.i, hNewHKey.i)
     
  global RegOverridePredefKey.RegOverridePredefKey_Prototype = GetFunction(Advapi32DLL, "RegOverridePredefKey")
EndIf
by

Code: Select all

lRet = RegOverridePredefKey(#HKEY_CLASSES_ROOT, hKey)
Before the call to RegOverridePredefKey it works; afterwards does not.

Do You know why this can happen?

I use the code above to enable OCX-controls without admin rights.

Thanks a lot!

Re: PB5.40LTS; ShellExecute_; mailto:

Posted: Mon Oct 19, 2015 3:09 pm
by HanPBF
hKey is received by a call to

Code: Select all

RegOpenKeyEx_(#HKEY_CURRENT_USER, "Software\Classes", 0, #KEY_READ, @hKey)
It seems I overwrite a whole key root with that trick...

(https://www.vb-paradise.de/index.php/Th ... g-und-ohn/)

Re: PB5.40LTS; ShellExecute_; mailto:

Posted: Mon Oct 19, 2015 3:30 pm
by HanPBF
These procedures make using this trick possible:

Code: Select all

Procedure   OverrideKey_DLL_ActiveX()
   Protected lRet,
             hKey,
             R
   
   R = 1
      
   If RegOpenKeyEx_(#HKEY_CURRENT_USER, "Software\Classes", 0, #KEY_READ, @hKey) = #ERROR_SUCCESS         ; override HKEY_CLASSES_ROOT
   	
      lRet = RegOverridePredefKey(#HKEY_CLASSES_ROOT, hKey)
      
      RegCloseKey_(hKey)
      
      If lRet = #ERROR_SUCCESS
         R = 0
      EndIf
   endif
   
   ProcedureReturn R
EndProcedure ; OverrideKey_DLL_ActiveX

Procedure RestoreOverrideKey_DLL_ActiveX()
   Protected      lRet,
                     R
   
   R = 1
   
   lRet = RegOverridePredefKey(#HKEY_CLASSES_ROOT, 0)      ; restore override of HKEY_CLASSES_ROOT
   
   If lRet = #ERROR_SUCCESS
       R = 0
   EndIf
   
   ProcedureReturn R
EndProcedure ; RestoreOverrideKey_DLL_ActiveX

When I then do this call, it works!

Code: Select all

RestoreOverrideKey_DLL_ActiveX()
  ShellExecute_(#Null, "open", MailTo, #Null, #Null, #SW_SHOWNORMAL)
OverrideKey_DLL_ActiveX()
Messing around with the registry is never a good idea; so is the registry itself...