Example 1
I am calling Win32Api kernel32.dll function [red]WinExec[/red] in the return line
lparameters pcExeName, pcParameters, [red]pnWindowStat[/red]
* first parameter required, other - optional
if Parameters() < 2.5 .or. type("pnWindowStat" != "N" .or. empty(pnWindowStat)
pnWindowStat = 1 && see Win32Api function ShowWindow for values of pnWindowStat
endif
local lcRunString
[red]m.lcRunString[/red] = '"'+ allt(m.pcExeName) + '"' + iif(parameters() > 1 , + " " + m.pcParameters , ""
[red]declare integer WinExec in kernel32 string lpCmdLine, integer uCmdShow[/red]
return [red]WinExec(m.lcRunString, m.pnWindowStat)[/red] > 31
endproc
Example 2
Here I'm call Win32Api advapi32.dll function [red]RegOpenKey[/red]
*procedure IsFileInReg
lparameters pcExeName
* returns fill path of EXE file taking it from Windows registry, or empty string
if empty(m.pcExeName) .or. type("m.pcExeName" != "C" .or. parameter() < 0.5
return ' '
endif
m.pcExeName = justfname(m.pcExeName)
...more code
local lnErrorRes, phkResult, lpSubKey, lpValue, lpcbValue
#define [red]HKEY_LOCAL_MACHINE[/red] -2147483646 && bitset(0,31)+2
[red]phkResult[/red] = 0
[red]lpSubKey[/red] = 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'
[red]lpValue[/red] = .null.
[red]declare long RegOpenKey in advapi32 long hKey, string lpSubKey, long @phkResult[/red]
lnErrorRes =[red] RegOpenKey(HKEY_LOCAL_MACHINE, lpSubKey, @phkResult)[/red]
if lnErrorRes # 0 or phkResult = 0 && Cannot open registry key - unknown error
= messagebox('Cannot open Windows registry.')
return ''
endif
... more code
Does This Help You ? [sig]<p>David W. Grewe<br><a href=mailtoave@internationalbid.net>Dave@internationalbid.net</a><br>[/sig]
Hi Jimmy,
IMO, you've just stumbled on one of VFP's few weaknesses. A struct, AISI, is nothing more than sequentially allocated memory space.
Handling structs from VFP requires creating a "buffer" to return the values, passing that buffer to the function by reference, and parsing the values out of that buffer. Here's an example of the GetSystemTime function:
DECLARE GetSystemTime IN WIN32API STRING @lcBuffer
*!* typedef struct _SYSTEMTIME {
*!* WORD wYear; && 2 bytes
*!* WORD wMonth; && 2 bytes
*!* WORD wDayOfWeek; && 2 bytes
*!* WORD wDay; && 2 bytes
*!* WORD wHour; && 2 bytes
*!* WORD wMinute; && 2 bytes
*!* WORD wSecond; && 2 bytes
*!* WORD wMilliseconds; && 2 bytes
*!* } SYSTEMTIME, *PSYSTEMTIME;
lcBuffer=SPACE(16) && total struct length is 16 bytes
*********************
FUNCTION Str2Word
*********************
PARAMETERS m.wordstr
PRIVATE i, m.retval
m.retval = 0
FOR i = 0 TO 8 STEP 8
m.retval = m.retval + (ASC(m.wordstr) * (2^i))
m.wordstr = RIGHT(m.wordstr, LEN(m.wordstr) - 1)
NEXT
RETURN m.retval
Str2Word is used to convert the returned value to WORD data type. [sig]<p>Jon Hawkins<br><a href=mailto: jonscott8@yahoo.com> jonscott8@yahoo.com</a><br><a href= > </a><br>Carpe Diem! - Seize the Day![/sig]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.