如何在Foxpro中调用Win32 api函数

如果我们需要使用Win32 API函数的WritePrivateProfileString
这个函数,那么我们先需要在调用这个函数的窗体内声明这个函数
如我们要在一个按钮的click函数内去执行,那么应这样写


 *-- 定义写应用程序 INI 文件的DLL函数
Declare Integer WritePrivateProfileString In Win32API As WritePrivStr  ;
 String cSection, String cKey, String cValue, String cINIFile
 
SET PATH TO "e:\foxproproject"
&&DO WriteIniFile in  writeinifile   with  "Hello world"
 writeIniFile("Hello world")

WriteIniFile.prg的内容

PROCEDURE WriteIniFile
 PARAMETERS lcValue
  conString="ConnectionString"
 lcEntry = "abc"
 =WritePrivStr(conString, lcEntry, lcValue, Curdir() + "formposi.ini")
  MESSAGEBOX(lcValue )
ENDPROC

 注:
 foxpro的注释标识符是&&,或者*|*
 我们在调用函数时,函数一般都写在prg文件中
 如果我们不想使用 Do function in prgfile with parameter的形式话
 就应将函数名与保存函数的文件名称一致

 curdir()是应用程序设置的路径,在执行完程序后,如果在当前路径下找不到formposi.ini文件,那么
 在命令窗口中执行?Curdir()命令,查看当前目录是那个目录

使用环境:vfp 9.0 sp2

原文地址:https://www.cnblogs.com/sunbingzibo/p/1237903.html