大家好。
我使用InternetQueryDataAvailable函数,得到的大小老是不对。代码如下:
hSession := InternetOpen('Delphi', 0, nil, nil, 0);
hConnection := InternetOpenURL(hSession, 'http://www.yahoo.com', nil, 0, 0, 0);
bResult := InternetQueryDataAvailable(hConnection, Size, 0, 0);如果改为使用
bResult := HttpQueryInfo(hConnection, HTTP_QUERY_CONTENT_LENGTH, @Buffer, iRead, iCount);却又返回ERROR_HTTP_HEADER_NOT_FOUND 错误, 太郁闷了。
麻烦大家帮忙看一下。一定给分。
我使用InternetQueryDataAvailable函数,得到的大小老是不对。代码如下:
hSession := InternetOpen('Delphi', 0, nil, nil, 0);
hConnection := InternetOpenURL(hSession, 'http://www.yahoo.com', nil, 0, 0, 0);
bResult := InternetQueryDataAvailable(hConnection, Size, 0, 0);如果改为使用
bResult := HttpQueryInfo(hConnection, HTTP_QUERY_CONTENT_LENGTH, @Buffer, iRead, iCount);却又返回ERROR_HTTP_HEADER_NOT_FOUND 错误, 太郁闷了。
麻烦大家帮忙看一下。一定给分。
解决方案 »
- 关于数据库有空格符的问题,怎么办
- 求最小生成树的算法
- 程序退出时总有一个这样的错误?请问高手如何跟踪调试呢?
- 如何阻止dxdbgrid处于编辑状态时失去焦点时自动更新数据集??
- 谁能列出一系列健值啊?急用,但又不知道在哪找!
- 一个小问题,如何限制窗体最小化的尺寸?
- Delphi界面工作一段时间后易跳消失的原因,求教各位。
- 用QuickRep生成的报表在HP上打印时总是分页,可怎么办呢?
- tcombobox的下拉框的列表宽度能不能改
- 如何将SQLServer的数据在DELPHI中转换成DBF?
- 请问怎样"固定"取得dbrgid中所选择的当前记录行中的某个字段值。(不能选其他字段)
- 向高手学习如何用Delphi多线程编程?
var
SearchRec: TSearchRec;
begin
//判断目录是否存在
if DirectoryExists(path) then
begin
//进入该目录,删除其中的子目录和文件
oldDir := GetCurrentDir;
ChDir(path);
//查找目录中所有任何文件
FindFirst(′.′, faAnyFile, SearchRec);
repeat
//修改文件属性为普通属性值
FileSetAttr(SearchRec.Name,0);
//如果是目录并且不是.和..则递归调用DelTree
if(SearchRec.Attr and faDirectory > 0) then
begin
if(SearchRec.Name[1]<>′.′) then
if(not Deltree(SearchRec.Name)) then
break;
end
//如果是文件直接删除
else
if(not DeleteFile(SearchRec.Name))then
break ;
//继续查找,直到最后
until (FindNext(SearchRec)<>0) ;
//回到父目录,删除该目录
ChDir(′..′);
Result := ReMoveDir(path);
SetCurrentDir(oldDir);
end
else
Result := False ;
end ;
该程序在Windows 98、Delphi 4.0下编译通过
BOOL HttpQueryInfo(
IN HINTERNET hRequest,
IN DWORD dwInfoLevel,
IN LPVOID lpvBuffer,
IN LPDWORD lpdwBufferLength,
IN OUT LPDWORD lpdwIndex,
);其中,lpdwIndex参数含义如下:
Address of a zero-based header index used to enumerate multiple headers with the same name. When calling the function, this parameter is the index of the specified header to return. When the function returns, this parameter is the index of the next header. If the next index cannot be found, ERROR_HTTP_HEADER_NOT_FOUND is returned. 我遇到的问题就是ERROR_HTTP_HEADER_NOT_FOUND错误,我不知道是什么原因。
SendStr:=SendStr+'Accept: */*'+#13#10;
SendStr:=SendStr+'Host: '+Host+#13#10;
SendStr:=SendStr+#13#10;
ClientSocket.Socket.SendText(SendStr);
while ClientSocket.Active do
begin
FStr:=TStringStream.Create('');
FSocketStream:= TWinSocketStream.Create(ClientSocket, TimeoutInt);
while ClientSocket.Connected do
begin
if not FSocketStream.WaitForData(TimeoutInt) then Break;
ZeroMemory(@Buf,SizeOf(Buf));
Res := FsocketStream.Read(Buf, 1);
if Res=0 then break;
FStr.Write(Buf,Res);
if Pos(#13#10,FStr.DataString)<>0 then
begin
Break;
end;
end;
CmdStr:=FStr.DataString;
if Pos(LowerCase('Content-Length: '),LowerCase(CmdStr))=1 then
begin
ValueInt:=StrToInt(Copy(CmdStr,Length('Content-Length: ')+1,Length(CmdStr)));
end;
end;