Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
GDI+: Storing content of the Clipboard to a bitmap file
How to change display settings: screen resolution, screen refresh rate
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
Custom GDI+ class
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
How to convert a bitmap file to monochrome format (1 bpp)
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
GDI+: Implementing image scrolling with inertia
Storing content of the Clipboard to a bitmap file
Retrieving the name of the primary domain controller (PDC) and join status information
Custom HttpRequest class (WinHTTP)
How to put a horizontal text scrolling on the form (a news line, marquee)
How to detect if additional monitor is connected and active
How to display Windows On-Screen Keyboard
Winsock: sending email messages (SMTP, port 25)
How to activate Windows Calculator
How to change the name and the size of the font in the MessageBox dialog
The SQLGetProp() creates a bridge between Visual FoxPro and the ODBC API
Custom HttpRequest class (WinINet)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to create MD-5 and SHA-1 hash values from a string
Mapping and disconnecting network drives
How to generate GUID values

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
Before you begin:
The result is returned in a format like that of the following sample:
{557cf400-1a04-11d3-9a73-0000f81ef32e}

See also:
  • Generating random UUID values
  • Generating sequential UUID values

  • DO declare
    
    LOCAL cGUID, cGUIDString, cGUID1
    cGUID = REPLICATE(CHR(0), 16)  && 128 bits
    
    IF CoCreateGuid(@cGUID) = 0
        cGUIDString = StringFromGUID(cGUID)
        ? cGUID
        ? cGUIDString
    
        * converting from String back to GUID
        cGUID1 = REPLICATE(CHR(0), 16)
        = CLSIDFromString(STRCONV(cGUIDString,5), @cGUID1)
        ? cGUID1
    ENDIF
    * end of main
    
    FUNCTION StringFromGUID(cGUID)
        LOCAL cBuffer, nBufsize
        nBufsize=128
        cBuffer = REPLICATE(CHR(0), nBufsize*2)
        = StringFromGUID2(cGUID, @cBuffer, nBufsize)
        cBuffer = SUBSTR(cBuffer, 1, AT(CHR(0)+CHR(0), cBuffer))
    RETURN STRCONV(cBuffer, 6)
    
    PROCEDURE declare
        DECLARE INTEGER CoCreateGuid IN ole32 STRING @pguid
    
        DECLARE INTEGER CLSIDFromString IN ole32;
            STRING lpsz, STRING @pclsid
    
        DECLARE INTEGER StringFromGUID2 IN ole32;
            STRING rguid, STRING @lpsz, INTEGER cchMax
    
    

    User rating: 9/10 (1 votes)
    Rate this code sample:
    • ~
    844 bytes  
    Created: 2004-07-15 13:24:36  
    Modified: 2013-10-01 12:23:16  
    Visits in 7 days: 52  
    Listed functions:
    CLSIDFromString
    CoCreateGuid
    StringFromGUID2
    Printer friendly API declarations
    My comment:
    The GUID is a unique 128-bit integer used for CLSIDs and interface identifiers.

    See also Microsoft Knowledge Base Article 269387 How To Obtain a GUID in Visual FoxPro

    * * *
    Having a connection to SQL Server, Guids can be generated with the NewId() function.
    FUNCTION NewGuid() As String
            IF SQLEXEC(1, "SELECT NewId() As guid", "csGuid") > 0
                    RETURN csGuid.guid
            ELSE
                    RETURN NULL
            ENDIF

    Another way is using the Scriptlet.TypeLib COM. Note that you must create a new instance of the class for each Guid to be generated, which probably produces some overhead.
    obj = CreateObject("Scriptlet.TypeLib")
    ? SUBSTR(obj.GUID,2,36)

    After a simple test I can estimate that the COM procedure is 5 to 10% faster than the SQL one (local server); and API is the winner creating GUID 15-20 times faster than COM -- for example, 0.24 seconds versus 4 seconds per 10,000 guids created.

    On the same computer C# code generated 1,000,000 guids in 1.05 seconds.
    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:
    A.M. | 2006-07-19 15:38:05
    DECLARE INTEGER UuidCreate IN rpcrt4 STRING @UUID

    Copyright 2001-2014 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.68), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.90.138.104)
    4 sec.Function: 'CreatePipe'
    9 sec.Example: 'Opening access to the Microsoft Internet functions for the application'
    15 sec.Example: 'How to print FoxPro form'
    23 sec.Function: 'StrFromTimeInterval'
    35 sec.Function: 'HeapReAlloc'
    Function group: 'Memory Management'
    45 sec.Function: 'mmioRead'
    Function group: 'Windows Multimedia'
    55 sec.Function: 'NetShareAdd'
    Function group: 'Network Management'
    1.2 min.Example: 'How to display Windows On-Screen Keyboard'
    Language: 'C#'
    1.65 min.Example: 'Displaying system dialog that selects a folder'
    Google
    Advertise here!