Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Converting Unicode data from the Clipboard to a character string using a given code page
Winsock: sending email messages (SMTP, port 25)
Enumerating data formats currently available on the clipboard
Custom FTP Class for Visual FoxPro application
Splash Screen for the VFP application
Detecting changes in connections to removable drives (VFP9)
How to activate Windows Calculator
How to download a file from the FTP server using FtpGetFile
How to put a vertical text scrolling on the form (a movie cast)
Custom HttpRequest class (WinHTTP)
Displaying bitmap using the AlphaBlend function
Establishing connection using the SQLDriverConnect
How to convert a bitmap file to monochrome format (1 bpp)
Mapping and disconnecting network drives
Using WM_COPYDATA for interprocess communication (VFP9)
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Using Font and Text functions
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
How to play AVI file on the _screen
StrDup returns a pointer to the duplicate of a source VFP string

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
 
DO decl
 
LOCAL lcSource, lcTarget, hMemory
lcSource = "Jack and Jill went up a hill"
hMemory = StrDup(lcSource)
 
IF hMemory <> 0
    ? "Pointer to a new string:", hMemory
 
    * copying from a pointer to a VFP string
    lcTarget = SPACE(250)
    = StrCpy (@lcTarget, hMemory)
    ? "Transferred string:", LEFT(lcTarget, AT(Chr(0), lcTarget)-1)
 
    * MSDN: The calling application must free this memory 
    * by calling the LocalFree function on the pointer 
    * returned by the call to StrDup. 
    = LocalFree (hMemory)
ELSE
* error
ENDIF
 
PROCEDURE  decl
    DECLARE INTEGER LocalFree IN kernel32 INTEGER hMem
    DECLARE INTEGER StrDup IN shlwapi STRING lpsz
    DECLARE INTEGER StrCpyW IN shlwapi AS StrCpy;
        STRING @psz1, INTEGER psz2
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
738 bytes  
Created: 2001-10-30 19:10:52  
Modified: 2001-11-02 18:55:49  
Visits in 7 days: 58  
Listed functions:
LocalFree
StrCpy
StrDup
Printer friendly API declarations
My comment:
For sure in many situations you can pass pointers to strings to external procedures just using STRING @.

But not when you need to fill a structure, which contains 4-byte pointers to strings. StrDup solves this problem easily, though you have an additional burden to free the allocated memory block.
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 sec.Example: 'Retrieving the name of the default printer for the current user on the local computer (Win NT/XP)'
6 sec.Example: 'Placing an arbitrary rectangular area of main VFP window on the Clipboard'
7.39 hrs.Function: 'EndUpdateResource'
 Function: 'GetSystemMenu'
7.41 hrs.Example: 'How to convert a bitmap file to monochrome format (1 bpp)'
Language: 'Visual FoxPro'
10.04 hrs.Example: 'Starting an external application in VFP using WinExec'
 Example: 'Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)'
10.82 hrs.Function: 'NetGetDCName'
Function group: 'Network Management'
17.46 hrs.Example: 'Get the power status of your laptop computer'
 Function: 'LookupPrivilegeDisplayName'
Google
Advertise here!