Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to empty the Recycle Bin
How to make a VFP form fading out when released (GDI+ version)
How to ping a remote site using IP Helper API calls
Reading the structure of VFP main menu
Retrieving information about the main VFP window
Retrieving the interface–to–IP address mapping table
Using custom Simple MapiSendMail class
Using File Mapping for enumerating files opened by Visual FoxPro
Using GetBinaryType (WinNT only) to determine the type of an executable file
Converting command-line string to a set of Unicode argument strings
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Displaying OS Memory Status
Enumerating Volumes and Volume Mounting Points (NTFS)
GDI+: Creating thumbnails to preview images in a directory
Generating random cryptographic keys
How to enable the SE_SHUTDOWN_NAME privilege for the application
PocketPC: custom RAPI class for executing routines on remote Windows CE device
Printing text on the client area of the main VFP window
Testing if a connection to an Url can be established
Using the GetTempFileName
Winsock: connecting to a news server (NNTP, port 119)
Creating hash values for the list of names
Deleting files into the Recycle Bin
Dial the Net Automatically
Verifying a file using the Authenticode policy provider

User rating: 10/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
Before you begin:
The following code sample has been developed by John L Veazey.

The WinVerifyTrust performs a trust verification action on a specified object. The function passes the inquiry to a trust provider that supports the action identifier, if one exists.
 
? WinVerifyTrust( "C:\Windows\System32\mscomct2.ocx" )
 
FUNCTION WinVerifyTrust
LPARAMETERS cFileName as String
LOCAL pFileName as String, cFileInfo as String,;
    pFileInfo as Integer, cWintrustInfo as String,;
    nResult as Integer
 
*!* Ensure the file exists.
IF NOT FILE(cFileName) THEN
    RETURN .F.
ENDIF
 
*!* Structure Sizes
*!*    GUID = 16 = 4 + 2 + 2 + (1 * 8)
*!* http://msdn.microsoft.com/en-us/library/aa373931%28v=VS.85%29.aspx
*!*    WINTRUST_FILE_INFO = 4 + 4(*) + 4 + 4(*)
*!* http://msdn.microsoft.com/en-us/library/aa388206%28v=VS.85%29.aspx
*!*    WINTRUST_DATA = 48 = 4 + 4 + 4 + 4 + 4 + 4 + 4(*) + 4 + 4 + 4(*) + 4 + 4
*!* http://msdn.microsoft.com/en-us/library/aa388205%28v=VS.85%29.aspx
 
DECLARE LONG WinVerifyTrust IN wintrust;
AS WinVerifyTrustAPI ;
    LONG, STRING, STRING
 
*!*    LONG WINAPI WinVerifyTrust(
*!*      __in  HWND hWnd,
*!*      __in  GUID *pgActionID,
*!*      __in  LPVOID pWVTData
*!*    );
*!*
 
DECLARE RtlMoveMemory IN WIN32API AS CopyMemory ;
    LONG, STRING, LONG
 
*!*    void CopyMemory(
*!*      __in  PVOID Destination,
*!*      __in  const VOID *Source,
*!*      __in  SIZE_T Length
*!*    );
*!*
 
DECLARE LONG GlobalAlloc IN WIN32API ;
    LONG, LONG
 
*!*    HGLOBAL WINAPI GlobalAlloc(
*!*      __in  UINT uFlags,
*!*      __in  SIZE_T dwBytes
*!*    );
*!*
 
DECLARE LONG GlobalFree IN WIN32API ;
    LONG
 
*!*    HGLOBAL WINAPI GlobalFree(
*!*      __in  HGLOBAL hMem
*!*    );
*!*
 
#DEFINE GMEM_ZEROINIT                    0x0040
#DEFINE WTD_UI_NONE                        2
#DEFINE WTD_REVOKE_NONE                    0x00000000
#DEFINE WTD_CHOICE_FILE                    1
#DEFINE WTD_STATEACTION_IGNORE            0x00000000
#DEFINE WTD_SAFER_FLAG                    0x00000100
#DEFINE WTD_UICONTEXT_EXECUTE            0
 
*!* Allocate UNICODE string
pFileName = GlobalAlloc(GMEM_ZEROINIT, ((LEN(cFileName) + 1) * 2))
*!* Copy filename to UNICODE
cFileName = STRCONV(STRCONV(cFileName,1),5)
*!* Copy UNICODE string to memory allocation
CopyMemory(pFileName, cFileName, LEN(cFileName))
*!* Allocate WINTRUST_FILE_INFO structure
pFileInfo = GlobalAlloc(GMEM_ZEROINIT, 16)
*!* Define contents of WINTRUST_FILE_INFO structure
cFileInfo = BINTOC(16, "4SR") + BINTOC(pFileName, "4SR") +;
    REPLICATE(CHR(0),4) + REPLICATE(CHR(0),4)
*!* Copy Struct data to memory allocation
CopyMemory(pFileInfo, cFileInfo, 16)
 
 
*!* {00AAC56B-CD44-11d0-8CC2-00C04FC295EE}
WINTRUST_ACTION_GENERIC_VERIFY_V2  =;
    BINTOC(0x00aac56b, "4SR") +;
    LEFT(BINTOC(0xcd44, "4SR"),2) +;
    LEFT(BINTOC(0x11d0, "4SR"),2) +;
    CHR(0x008c) + CHR(0x00c2) + CHR(0x0000) + CHR(0x00c0) +;
    CHR(0x004f) + CHR(0x00c2) + CHR(0x0095) + CHR(0x00ee)
 
cWintrustInfo =;
    BINTOC(48, "4SR") +;
    REPLICATE(CHR(0),4) +;
    REPLICATE(CHR(0),4) +;
    BINTOC(WTD_UI_NONE, "4SR") +;
    BINTOC(WTD_REVOKE_NONE, "4SR") +;
    BINTOC(WTD_CHOICE_FILE, "4SR") +;
    BINTOC(pFileInfo, "4SR") +;
    BINTOC(WTD_STATEACTION_IGNORE, "4SR") +;
    REPLICATE(CHR(0),4) +;
    REPLICATE(CHR(0),4) +;
    BINTOC(WTD_SAFER_FLAG, "4SR") +;
    BINTOC(WTD_UICONTEXT_EXECUTE, "4SR")
 
nResult = WinVerifyTrustAPI(0, WINTRUST_ACTION_GENERIC_VERIFY_V2,;
    cWintrustInfo)
 
GlobalFree(pFileInfo)
GlobalFree(pFileName)
 
RETURN nResult == 0
ENDFUNC
 

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
3133 bytes  
Created: 2010-10-07 08:14:17  
Modified: 2010-10-07 08:24:58  
Visits in 7 days: 31  
Listed functions:
CopyMemory
GlobalAlloc
GlobalFree
WinVerifyTrust
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-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.243.204)
1.57 min.Example: 'How to generate GUID values'
4.63 min.Function: 'SQLManageDataSources'
8.65 hrs.Example: 'Reading and setting explicit Application User Model ID for the current process (Win7)'
8.66 hrs.Function: 'inet_ntoa'
 Function: 'waveOutUnprepareHeader'
Function group: 'Windows Multimedia'
8.68 hrs.Example: 'How to perform Base64 encoding/decoding using Cryptography API Functions'
8.69 hrs.Function: 'GdipDrawRectangle'
8.72 hrs.Function: 'LogonUser'
2 day(s)Function: 'RegEnumKey'
Function group: 'Registry'
 
Function group: 'Remote Access Service (RAS)'
Google
Advertise here!