Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to obtain the number of rows affected by remote UPDATE, INSERT or DELETE statement
Number of clipboard formats available
Using the CreateFile
Using the heap of the calling process to allocate memory blocks
Wininet last error description
Enhanced GetFont dialog
Extracting the name and extension parts of a path string
How to display picture stored in enhanced-format metafile (*.emf)
How to intercept window messages sent to VFP form
Listing INF files in a specified directory
Uploading file to the FTP server using InternetWriteFile
Obtaining a handle to the desktop associated with the calling thread
Retrieving list of Global Atom names
Retrieving System Error message strings
Using Beep and Sleep functions to make the old tin buzz sing (WinNT only?)
Validating URLs using moniker functions
Enumerating files opened on the network
GDI+: cropping images
GDI+: Using Scale and Shear transformations
How to empty the Recycle Bin
Converting path to original case
Using GetSysColor
Validating the heap of the calling process
CryptoAPI: retrieving list of providers
Testing MS Internet Explorer version installed

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
 
DO decl
? "*** MSIE Version installed"
? "Version:   ", GetHKLM("Version")
? "Build:     ", GetHKLM("Build")
? "Product ID:", GetHKLM("ProductID")
? "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 decl
    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:
  • ~
2151 bytes  
Created: 2001-09-09 12:00:00  
Modified: 2003-07-11 11:43:34  
Visits in 7 days: 110  
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.
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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (23.20.196.179)
4.17 hrs.Example: 'Storing screen shot of a form to enhanced metafile (*.emf)'
 Function: 'WNetGetUniversalName'
 Example: 'Obtaining I/O counts for the current process'
5.92 hrs.Example: 'Using the SetErrorMode for determining if a floppy drive is ready'
11.24 hrs.Function: 'FindNextPrinterChangeNotification'
Function group: 'Printing and Print Spooler'
 Function: 'ExitWindowsEx'
Function group: 'System Shutdown'
14.26 hrs.Example: 'GDI+: cropping images'
2 day(s)Example: 'How to print picture stored in enhanced-format metafile (*.emf)'
 Function: 'GetThreadLocale'
 Example: 'StrDup returns a pointer to the duplicate of a source VFP string'
Google
Advertise here!