Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opening each url in separately default web browser
Message
From
27/11/2006 17:24:41
 
 
To
25/11/2006 23:48:21
Reza Meamar
Homa Programming Group
Shiraz, Iran
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01172447
Message ID:
01172775
Views:
23
This message has been marked as the solution to the initial question of the thread.
Hi!

Try next code.

Regards,
Sergey
DECLARE INTEGER ShellExecute IN Shell32.DLL;
        INTEGER nWinHandle,;
        STRING  cOperation,;
        STRING  cFileName,;
        STRING  cParameters,;
        STRING  cDirectory,;
        INTEGER nShowWindow

DECLARE INTEGER RegOpenKey IN Win32API;
        INTEGER nHKey,;
        STRING  sSubKey,;
        INTEGER @nHandle

DECLARE INTEGER RegCloseKey IN Win32API;
        INTEGER nHKey

DECLARE INTEGER RegQueryValueEx IN Win32API;
        INTEGER nHKey,;
        STRING  sValueName,;
        INTEGER nReserved,;
        INTEGER @nType,;
        STRING  @sData,;
        INTEGER @nData
*---------------------------

PUBLIC SysIE_Default
SysIE_Default= "?"  &&default Internet Browser

=ShowWeb("http://www.levelextreme.com", .F.)
=ShowWeb("http://www.levelextreme.com", .F.)
=ShowWeb("http://www.levelextreme.com", .F.)

RETURN

*=============================================
FUNCTION GetRegistryValue(sKey, sSubKey, sEntry)
* In: sKey - "Root", "Local", "User", "Users"
*     sSubKey - the registry subkey (e.g. "http\shell\open\command")
*     sEntry  - the actual key
* Returns a value from the registry.

LOCAL rc, sKeyU, nKey, nHandle, nSize, sData, nType

#DEFINE HKEY_CLASSES_ROOT  0x80000000
#DEFINE HKEY_CURRENT_USER  0x80000001
#DEFINE HKEY_LOCAL_MACHINE 0x80000002
#DEFINE HKEY_USERS         0x80000003

sKeyU= UPPER(sKey)
nKey= IIF(sKeyU=="ROOT",  HKEY_CLASSES_ROOT,;
      IIF(sKeyU=="LOCAL", HKEY_LOCAL_MACHINE,;
      IIF(sKeyU=="USER",  HKEY_CURRENT_USER,;
      IIF(sKeyU=="USERS", HKEY_USERS,;
                          0 ))))

nHandle= 0

rc= RegOpenKey(nKey, sSubKey, @nHandle)
IF rc#0
   RETURN ""
ENDIF   

nSize= 512
sData= SPACE(nSize)
nType= 4 &&integer 4 bytes

rc= RegQueryValueEx(nHandle, sEntry, 0, @nType, @sData, @nSize)
IF rc#0
   RETURN ""
ENDIF   


=RegCloseKey(nHandle)

RETURN IIF(rc#0, "",;
       IIF(nSize<=1, "",;
              SUBSTR(sData, 1, nSize-1))) &&erase last chr(0)

*=============================================
PROCEDURE GetIE_Default()

IF !SysIE_Default=="?"
	RETURN
ENDIF

LOCAL sIE, i1, i2

SysIE_Default= ""

sIE= GetRegistryValue("Root", "http\shell\open\command", "")

i1= AT(["], sIE, 1)
i2= AT(["], sIE, 2)
IF i1#0 .and. i2#0
	SysIE_Default= SUBSTR(sIE, i1+1, i2-i1-1)
ENDIF

RETURN

*=============================================
PROCEDURE ShowWeb(sURL, FlgOld)

IF EMPTY(sURL)
	=WMsg("!", "There is no URL to show.")
	RETURN
ENDIF
	
LOCAL rc

rc= FlgOld
IF !rc
	=GetIE_Default()
	rc= EMPTY(SysIE_Default) &&
ENDIF

IF rc &&use old browser
	ShellExecute(0, "open", sURL, "", "", 1)
ELSE &&launch new browser
	ShellExecute(0, "open", SysIE_Default, sURL, "", 1)
ENDIF

RETURN
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform