Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Converting Unicode data from the Clipboard to a character string using a given code page
Custom FTP Class for Visual FoxPro application
Custom HttpRequest class (WinINet)
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Establishing connection using the SQLDriverConnect
How to make a VFP form fading out when released (GDI+ version)
How to make a VFP form fading out when released (GDI version)
Using FlashWindowEx to flash the taskbar button of the VFP application
Splash Screen for the VFP application
How to put a vertical text scrolling on the form (a movie cast)
Winsock: sending email messages (SMTP, port 25)
How to create non-blocking Winsock server
Creating a mailslot
Peer-to-peer LAN messenger built with Mailslot API functions
Using WM_COPYDATA for interprocess communication (VFP9)
How to print a bitmap file
Class for sound recording
Sending a standard message with one or more attached files using default email client
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Creating a unique filename based on existing filename

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
 
#DEFINE CP_ACP         0
#DEFINE CP_OEMCP       1
#DEFINE MB_PRECOMPOSED 1
#DEFINE MAX_PATH       260
DO decl
 
LOCAL cPath, cFile, cUnique, cTpl
 
* retrieving FoxPro executable name
cPath = Repli(Chr(0),MAX_PATH)
= GetModuleFileName(0, @cPath, Len(cPath))
cPath = SUBSTR(cPath, 1, AT(Chr(0),cPath)-1)
cFile = SUBSTR(cPath, RAT("\",cPath)+1)
? "Base name:", cPath
 
cUnique = Repli(Chr(0),MAX_PATH*2)
= PathYetAnotherMakeUniqueName(@cUnique, a2u(cPath), Null, a2u(cFile))
cUnique = u2a(cUnique)
? "Unique filename:", cUnique
?
 
cUnique = Repli(Chr(0),MAX_PATH*2)
cTpl = "MyFile.Dat"
cPath = GetLongTempPath()
? "Base name:", cPath + cTpl
 
= PathMakeUniqueName(@cUnique, MAX_PATH, a2u(cTpl), a2u(cTpl), a2u(cPath))
cUnique = u2a(cUnique)
? "Unique filename:", cUnique
* end of main
 
FUNCTION GetLongTempPath
    LOCAL cPath, cLongPath, nBufsize
    cPath = Repli(Chr(0),MAX_PATH)
    cLongPath = Repli(Chr(0),MAX_PATH*2)
    nBufsize = GetTempPath(Len(cPath), @cPath)
    cPath = LEFT(cPath, nBufsize)
    = GetLongPathName(cPath, @cLongPath, Len(cLongPath))
RETURN SUBSTR(cLongPath, 1,AT(Chr(0),cLongPath)-1)
 
FUNCTION u2a(cText)
* converting a Unicode string to an ANSI string
    LOCAL lcBuffer, lnBufsize
    cText = SUBSTR(cText, 1, AT(Chr(0)+Chr(0),cText))
 
    * first calling to define required buffer size
    lcBuffer = ""
    lnBufsize = WideCharToMultiByte(CP_ACP, 0,;
        cText, Len(cText), @lcBuffer, 0, Chr(0), 0)
 
    lcBuffer = Repli(Chr(0), lnBufsize)
    = WideCharToMultiByte(CP_ACP, 0,;
        cText, Len(cText), @lcBuffer, lnBufsize, Chr(0), 0)
RETURN SUBSTR(lcBuffer, 1, AT(Chr(0),lcBuffer)-1)
 
FUNCTION a2u(cText)
* converting an ANSI string to a Unicode string
    LOCAL lcBuffer, lnBufsize
 
    * first calling to define required buffer size
    lcBuffer = ""
    lnBufsize = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,;
        cText, Len(cText), @lcBuffer, 0)
 
    lcBuffer = Repli(Chr(0), lnBufsize*2)  && in wide chars
    = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,;
        cText, Len(cText), @lcBuffer, lnBufsize)
RETURN lcBuffer
 
PROCEDURE decl
    DECLARE INTEGER PathMakeUniqueName IN shell32;
        STRING @pszUniqueName, INTEGER cchMax, STRING pszTemplate,;
        STRING pszLongPlate, STRING pszDir
 
    DECLARE INTEGER PathYetAnotherMakeUniqueName IN shell32;
        STRING @pszUniqueName, STRING pszPath,;
        STRING pszShort, STRING pszFileSpec
 
    DECLARE INTEGER GetTempPath IN kernel32;
        INTEGER nBufferLength, STRING @lpBuffer
 
    DECLARE INTEGER GetLongPathName IN kernel32;
        STRING lpszShortPath, STRING @lpszLongPath,;
        INTEGER cchBuffer
 
    DECLARE INTEGER GetModuleFileName IN kernel32; 
        INTEGER hModule, STRING @lpFilename, INTEGER nSize
 
    DECLARE INTEGER WideCharToMultiByte IN kernel32;
        INTEGER CodePg, INTEGER dwFlags,;
        STRING lpWideCharStr, INTEGER cchWideChar,;
        STRING @lpMultiByteStr, INTEGER cbMultiByte,;
        STRING lpDefaultChar, INTEGER lpUsedDefaultChar
 
    DECLARE INTEGER MultiByteToWideChar IN kernel32;
        INTEGER CodePage, LONG dwFlags, STRING lpMultiByteStr,;
        INTEGER cbMultiByte, STRING @lpWCharStr, INTEGER cchWChar
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
3092 bytes  
Created: 2001-07-12 12:00:00  
Modified: 2005-12-12 11:26:21  
Visits in 7 days: 56  
Listed functions:
GetLongPathName
GetModuleFileName
GetTempPath
MultiByteToWideChar
PathMakeUniqueName
PathYetAnotherMakeUniqueName
WideCharToMultiByte
Printer friendly API declarations
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.
Google
Advertise here!