为什么我在PB6。5下调用wininet.dll中的API总是出错?每个函数PB都说调用外部函数错误!

overflow2002 2002-01-24 03:45:52
比如internetopen函数,函数声明如下:
function long internetopen(string lpszAgent,long dwAccessType,string lpszProxyName , string lpszProxyBypass , long dwFlags) library "wininet.dll"

运行时总是出现
Error:Error calling external function internetopen at .....的错误!
就算写成
function long internetopen(string lpszAgent,long dwAccessType,string lpszProxyName , string lpszProxyBypass , long dwFlags) library "wininet.dll" alias for "internetopena"
也无济于事。
在WIN98 ,2000下都不成功。
...全文
97 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
我看VC中FindFirstFile第二个参数传递的是一个指针对象
PB怎么办呢??
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
西西~~,老天爱笨小孩
搞定一半了
声明应该是这样的:
FUNCTION ulong FindFirstFile( string lpFileName, WIN32_FIND_DATA lpFindFileData) LIBRARY "kernel32.dll" ALIAS FOR "FindFirstFileA"

现在另一半的问题是:我的WIN32_FIND_DATA 变量收不到数据,始终是空的
WHY???
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
吐血~~~
小草,还是不行啊:(~~
THANKS ANYWAY
:(~~~
bency 2002-05-10
  • 打赏
  • 举报
回复
long dwFileAttributes
filetime ftCreationTime
filetime ftLastAccessTime
filetime ftLastWriteTime
long nFileSizeHigh
long nFileSizeLow
long dwReserved0
long dwReserved1
string cFileName[]
string cAlternate[]
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
那我的win32_find_data应该怎么定义呢
bency(小草) ,麻烦你在我上边改改看:)
bency 2002-05-10
  • 打赏
  • 举报
回复
你把结构filetime不要,cFilename,cAlternate换成数组
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
我是从VB里移植过来的
在VB下可以用
为什么PB下老出毛病??
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
Function Long FindFirstFile(string lpFileName,WIN32_FIND_DATA lpFindFileData )Library "kernel32.DLL"

用到的两个数据类型FILETIME,WIN32_FIND_DATA
结构:
$PBExportHeader$filetime.srs
global type filetime from structure
long dwLowDateTime
long dwHighDateTime
end type

$PBExportHeader$win32_find_data.srs
global type win32_find_data from structure
long dwFileAttributes
filetime ftCreationTime
filetime ftLastAccessTime
filetime ftLastWriteTime
long nFileSizeHigh
long nFileSizeLow
long dwReserved0
long dwReserved1
string cFileName
string cAlternate
end type
zhangxuehun 2002-05-10
  • 打赏
  • 举报
回复
在PB中调用API时必须注意两个问题:
1。声明时,必须取分大小写,一定!!!
2。调用时,必须传入合适的参数。
bency 2002-05-10
  • 打赏
  • 举报
回复
你是怎样定义的贴出来
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
typedef struct _WIN32_FIND_DATA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
TCHAR cFileName[ MAX_PATH ];
TCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATA, *PWIN32_FIND_DATA;

这是微软WIN32_FIND_DATA的定义
数目和类型都对上了,最后一个名字不对,我改过后,还是出错
bency 2002-05-10
  • 打赏
  • 举报
回复
你在win32_find_data 中是不是所有参数都定义了
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
:(~
换成any还是一样的错误提示
这是我导出的结构:
$PBExportHeader$win32_find_data.srs
global type win32_find_data from structure
long dwFileAttributes
filetime ftCreationTime
filetime ftLastAccessTime
filetime ftLastWriteTime
long nFileSizeHigh
long nFileSizeLow
long dwReserved0
long dwReserved1
string cFileName
string cAlternate
end type
bency 2002-05-10
  • 打赏
  • 举报
回复
好象没问题
FUNCTION ulong SetLocalTime(any lpSystemTime) LIBRARY "kernel32.dll"

你把WIN32_FIND_DATA换成any
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
WIN32_FIND_DATA结构中有个
cFileName As String * MAX_PATH
cAlternate As String * 14

我给声明成string了
问题在这?
bency 2002-05-10
  • 打赏
  • 举报
回复
例如:
结构:str_systime(unsignedinteger:year,month,day,hour,minute,second)

datetime dt_server
str_systime lstr_tmp

select getdate() into :dt_server from sysfiles;
lstr_tmp.year=year(date(dt_server))
lstr_tmp.month=month(date(dt_server))
lstr_tmp.week=daynumber(date(dt_server)) - 1
lstr_tmp.day=day(date(dt_server))
lstr_tmp.hour=hour(time(dt_server))
lstr_tmp.minute=minute(time(dt_server))
lstr_tmp.second=second(time(dt_server))

SetLocalTime(lstr_tmp)
bency 2002-05-10
  • 打赏
  • 举报
回复
你的结构要和WIN32_FIND_DATA参数一一对应,你对吗
bency 2002-05-10
  • 打赏
  • 举报
回复
你的结构是怎样定义的,你查一下书,要和它的结构一一参数对应
侠雨飞飞 2002-05-10
  • 打赏
  • 举报
回复
Function Long FindFirstFile(string lpFileName,WIN32_FIND_DATA lpFindFileData )Library "kernel32.DLL"

WIN32_FIND_DATA 我定义了一个结构

??
bency 2002-05-10
  • 打赏
  • 举报
回复
1、function long internetopenA(string lpszAgent,long dwAccessType,string lpszProxyName , string lpszProxyBypass , long dwFlags) library "wininet.dll"
试试
2、你的外部函数参数对吗???有没有原形,贴出来看看


加载更多回复(3)

401

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 非技术版
社区管理员
  • 非技术版社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧