Using Win32 functions in Visual FoxPro Image Gallery
URL Monikers
..msdn
CreateURLMonikerEx
FindMediaType
IsValidURL
ObtainUserAgentString
URLDownloadToCacheFile
URLDownloadToFile
UrlMkGetSessionOption
Code examples:
Obtaining current Internet Explorer browser version and UserAgent
Obtaining current Internet Explorer browser version and UserAgent

User rating: 9/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
DO declare

? "*** MSIE Version installed"
? "Version:   ", GetHKLM("Version")
? "Build:     ", GetHKLM("Build")
? "User Agent:", GetUserAgent1()
* end of main

FUNCTION GetHKLM(lcValue)  && reading LOCAL_MACHINE registry data
#DEFINE HKEY_LOCAL_MACHINE 0x80000002
#DEFINE ccKey "Software\Microsoft\Internet Explorer"
#DEFINE ERROR_SUCCESS 0
#DEFINE KEY_READ 131097

    LOCAL hKey, lcData, lnSize, lcResult
    hKey = 0

    * opening specified key
    IF RegOpenKeyEx(HKEY_LOCAL_MACHINE,;
        ccKey, 0, KEY_READ, @hKey) <> ERROR_SUCCESS
        RETURN "#error#"
    ENDIF

    lnSize = 250
    lcData = SPACE(lnSize)

    * quering the value name
    IF RegQueryValueEx(hKey, lcValue,;
        0,0, @lcData, @lnSize) = ERROR_SUCCESS
        lcResult = Left(lcData, lnSize-1)
    ELSE
        lcResult = "#not found#"
    ENDIF

    = RegCloseKey (hKey)  && releasing key handle
RETURN lcResult

FUNCTION GetUserAgent  && returns the user agent string in use
#DEFINE URLMON_OPTION_USERAGENT 0x10000001
    LOCAL nBufsize, cBuffer
    nBufsize = 0
    cBuffer = Repli(Chr(0), 250)
    nResult = UrlMkGetSessionOption(URLMON_OPTION_USERAGENT,;
        @cBuffer, Len(cBuffer), @nBufsize, 0)
RETURN SUBSTR(cBuffer, 1, nBufsize)

FUNCTION GetUserAgent1  && returns the user agent string in use
    LOCAL nBufsize, cBuffer
    nBufsize = 250
    cBuffer = Repl(Chr(0), nBufsize)
    IF ObtainUserAgentString(0, @cBuffer, @nBufsize) = 0
        RETURN PADR(cBuffer, nBufsize)
    ENDIF
RETURN ""

PROCEDURE declare
    DECLARE INTEGER RegCloseKey IN advapi32 INTEGER hKey

    DECLARE INTEGER RegOpenKeyEx IN advapi32;
        INTEGER hKey, STRING lpSubKey, INTEGER ulOptions,;
        INTEGER samDesired, INTEGER @phkResult

    DECLARE INTEGER RegQueryValueEx IN advapi32;
        INTEGER hKey, STRING lpValueName, INTEGER lpReserved,;
        INTEGER @lpType, STRING @lpData, INTEGER @lpcbData

    DECLARE INTEGER UrlMkGetSessionOption IN urlmon;
        INTEGER dwOption, STRING @pBuffer, INTEGER dwBufferLen,;
        INTEGER @pdwBufferLen, INTEGER dwReserved

    DECLARE INTEGER ObtainUserAgentString IN urlmon;
        INTEGER dwOption, STRING @pcszUAOut, INTEGER @cbSize

User rating: 9/10 (1 votes)
Rate this code sample:
  • ~
2087 bytes  
Created: 2001-09-09 12:00:00  
Modified: 2013-11-17 18:01:53  
Visits in 7 days: 127  
Listed functions:
ObtainUserAgentString
RegCloseKey
RegOpenKeyEx
RegQueryValueEx
UrlMkGetSessionOption
Printer friendly API declarations
My comment:
The UrlMkGetSessionOption is used to obtain current User Agent string. As far as I checked this string is not stored in Windows Registry as a single key value.

The UrlMkSetSessionOption can be used for changing the user agent string for the process.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright 2001-2017 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.198.246.116)
9 sec.Function: 'GdipGetDpiY'
Function group: 'GDI+ Graphics'
28 sec.Function: 'UnlockFile'
Function group: 'File Management'
43 sec.Function: 'DestroyMenu'
Function group: 'Menu'
1.02 min.Function: 'ImageList_Destroy'
1.58 min.Function: 'AVIStreamTimeToSample'
Function group: 'Windows Multimedia'
1.83 min.Function: 'GdipGetPropertyItemSize'
Function group: 'GDI+ Image'
2.15 min.Function: 'CryptDeriveKey'
Function group: 'Cryptography Reference'
2.35 min.Function: 'WSAGetLastError'
Function group: 'Windows Sockets 2 (Winsock)'
2.6 min.Example: 'Downloading files from the FTP server using InternetReadFile'
2.87 min.Articles
Google
Advertise here!