调用windows API以取得当前路径的函数声明如下:
Function ulong GetCurrentDirectoryA(ulong nBufferLength,ref string lpBuffer) Library "kernel32.dll"
在主窗口的open事件中
gs_appdir=Space(255) //保存在全局变量中
IF GetCurrentDirectoryA(255,gs_appdir) = 0 THEN
messagebox("错误","不能取得应用程序的当前工作路径。请与开发商联系。",information!)
halt
end if