Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Creating two-byte hashes for a list of URLs
Listing device drivers in the system: load addresses, names
Who owns the Windows Clipboard
Winsock: retrieving the host information corresponding to a network address
Enumerating Performance Counters
Closing Windows
Who is the first in viewing the Clipboard
Accessing a CD device (cdaudio) with Multimedia Command Strings
Open and close a Simple MAPI Session
Using SQLBrowseConnect to connect to a data source through a number of iterative calls (SQL Server)
Enumerating forms supported by a specified printer
How to create a service object
Using Video Capture: enumerating installed capture drivers
Displaying the color palette stored in an image file
Retrieving a handle to DLL and address of an exported function in it
Retrieving the path of the printer-driver directory and printer-processor directory
Using Custom FTP class (DEFINE CLASS ftp As Custom)
How to delete a service object
Hiding mouse cursor
List of addresses in the AutoDial mapping database
Setting the last-error code for the FoxPro
Using GetCompressedFileSize (WinNT only)
Reading virtual key status values and key names
Obtaining the System and Windows folder names
How to fill a buffer with random bytes using Cryptography API Functions

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
Before you begin:
Use this code to fill a large buffer (a string) with random characters. MS even insists that these characters would be far more random than any created by standard random function.
 
#DEFINE PROV_RSA_FULL 1
#DEFINE CRYPT_VERIFYCONTEXT 0xf0000000
DO declare
 
LOCAL hProvider, cBuffer
hProvider=0
 
* obtain CSP handle
IF CryptAcquireContext(@hProvider, NULL, NULL,;
    PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) = 0
    ? "Call to CryptAcquireContext failed:", GetLastError()
    RETURN
ENDIF
 
* allocate buffer that will receive random data
cBuffer = REPLICATE(CHR(0), 1024)
 
* fill the buffer with cryptographically random bytes
IF CryptGenRandom(m.hProvider, LEN(m.cBuffer), @cBuffer) = 0
    ? "Call to CryptGenRandom failed:", GetLastError()
ELSE
    CREATE CURSOR cs (randbytes M)
    INSERT INTO cs VALUES (m.cBuffer)
    MODIFY MEMO randbytes NOWAIT
ENDIF
 
= CryptReleaseContext(m.hProvider, 0)
* end of main
 
PROCEDURE declare
    DECLARE INTEGER GetLastError IN kernel32
 
    DECLARE INTEGER CryptGenRandom IN advapi32;
        INTEGER hProv, LONG dwLen, STRING @pbBuffer
 
    DECLARE INTEGER CryptAcquireContext IN advapi32;
        INTEGER @hProvHandle, STRING cContainer, ;
        STRING cProvider, INTEGER nProvType, INTEGER nFlags
 
    DECLARE INTEGER CryptReleaseContext IN advapi32;
        INTEGER hProvHandle, INTEGER nReserved
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1139 bytes  
Created: 2001-07-19 12:00:00  
Modified: 2010-08-05 10:00:28  
Visits in 7 days: 45  
Listed functions:
CryptAcquireContext
CryptGenRandom
CryptReleaseContext
GetLastError
Printer friendly API declarations
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 (50.16.36.153)
13.18 min.Example: 'Simple MAPI: how to pick an email recipient from Outlook Express address book'
13.28 min.Function: 'InternetOpenUrl'
1.25 hrs.Example: 'Round FoxPro form'
 Example: 'Using the IsWindowEnabled function'
2.24 hrs.Example: 'Displaying system dialog that selects a folder'
 Example: 'How to display Windows On-Screen Keyboard'
Language: 'C#'
4.03 hrs.Example: 'How to download this reference`s archive through WinInet functions using InternetOpenUrl'
 Example: 'Enumerating print processors and supporting data types installed on the specified server'
 Function: 'FindClosePrinterChangeNotification'
Function group: 'Printing and Print Spooler'
5.1 hrs.Example: 'How to write and read Window Properties for the specified window'
Google
Advertise here!