用delphi写一个隐藏运行程序,3分钟后获取本机IP并发送到指定asp空间记录到txt文件里 ,代码应该怎么写,asp的代码应该怎么样才可以接受呢,请大侠指教
解决方案 »
- 怎么delphi5的ADO能连接上网站数据库,delphi7就不行?
- 一个比较高深的问题?
- 一个乱七八糟的BUG。。。。
- 急,我把原来的数据库删除了,重新建了一个数据库,但编译的时候还提示找不到原来的数据库,怎么解决啊???
- 菜鸟问题:关于UdpSockets的SendTo方法!
- web browser简单问题
- api高手看过来,很容易弄分的哦!
- 关于计算字段的问题?
- 100分寻求软件或实现代码,不知道是不是很菜的问题
- 请问如何设置拖放的图标(DragCursor),即用自定义的图标,而不是crDrag等系统指定的图标?
- Parent, Self 和 %d, %d [新手]
- delphi WM_GETTEXT 取得其他软件上的中文?
在任务栏不可见?简单了。
在进程里不可见?可注入
和ASP的通讯更简单。IDhttp,网你的ASP网站上提交数据就行了。
能不能把程序发给我下 谢谢了
我的QQ;41509647
邮箱;[email protected]
unit UrlPost;interfacefunction HtmlEncode(s: string): string;
procedure PostURL(const aUrl: string; FTPostQuery: string);implementationuses
Windows, WinInet;function HtmlEncode(s: string): string;
var
i, v1, v2: integer;
function i2s(b: byte): char;
begin
if b <= 9 then result := chr($30 + b)
else result := chr($41 - 10 + b);
end;
begin
result := '';
for i := 1 to length(s) do
if s[i] = ' ' then result := result + '+'
else if (s[i] < ' ') or (s[i] in ['/', '\', ':', '&', '?', '|']) then
begin
v1 := ord(s[i]) mod 16;
v2 := ord(s[i]) div 16;
result := result + '%' + i2s(v2) + i2s(v1);
end
else result := result + s[i];
end;procedure PostURL(const aUrl: string; FTPostQuery: string);
var
hSession: HINTERNET;
hConnect, hRequest: hInternet;
lpBuffer: array[0..1024 + 1] of Char;
dwBytesRead: DWORD;
HttpStr:String;
HostName, FileName: String;
FTResult: Boolean;
AcceptType: LPStr;
Buf: Pointer;
dwBufLen, dwIndex: DWord;
// 字符串转小写
function LowerCase(const Source: string): string;
var
TempChar: Char;
StrLen: Integer;
PSource,
PDest: PChar;
begin
StrLen := Length(Source);
SetLength(Result, StrLen); PSource := @Source[1];
PDest := @Result[1]; while (StrLen > 0) do
begin
TempChar := PSource^;
if (TempChar >= 'A') and (TempChar <= 'Z') then Inc(TempChar, 32);
PDest^ := TempChar;
Inc(PSource);
Inc(PDest);
Dec(StrLen);
end;
end;
procedure ParseURL(URL: String; var HostName, FileName: String);
procedure ReplaceChar(c1, c2: Char; var St: String);
var
p: Integer;
begin
while True do
begin
p := Pos(c1, St);
if p = 0 then Break
else St[p] := c2;
end;
end;
var
i: Integer;
begin
if Pos(LowerCase('http://'), LowerCase(URL)) <> 0 then
System.Delete(URL, 1, 7);
i := Pos('/', URL);
HostName := Copy(URL, 1, i);
FileName := Copy(URL, i, Length(URL) - i + 1);
if (Length(HostName) > 0) and (HostName[Length(HostName)] = '/') then
SetLength(HostName, Length(HostName) - 1);
end;
begin
hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
if Assigned(hSession) then
begin
ParseURL(aUrl, HostName, FileName);
hConnect := InternetConnect(hSession, PChar(HostName),
INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0); AcceptType := PChar('Accept: */*'); hRequest := HttpOpenRequest(hConnect, 'POST', PChar(FileName), 'HTTP/1.0',
nil, @AcceptType, INTERNET_FLAG_RELOAD, 0);
//
HttpSendRequest(hRequest, 'Content-Type: application/x-www-form-urlencoded', 47,
PChar(FTPostQuery), Length(FTPostQuery)); dwIndex := 0;
dwBufLen := 1024;
GetMem(Buf, dwBufLen);
FTResult := HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH,
Buf, dwBufLen, dwIndex);
if FTResult=True then
try
while True do
begin
dwBytesRead := 1024;
InternetReadFile(hRequest, @lpBuffer, 1024, dwBytesRead);
if dwBytesRead = 0 then break;
lpBuffer[dwBytesRead] := #0;
HttpStr:=HttpStr+lpBuffer;
end;
finally
InternetCloseHandle(hRequest);
InternetCloseHandle(hConnect);
end;
end;
finally
InternetCloseHandle(hSession);
end;
end;end.以上保存为 UrlPost.pas<%
strLogFile = "bobo.txt"Number = request("Number")if Number = "" then
response.end
End IfStrLogText = Numberset f=Server.CreateObject("scripting.filesystemobject")
set ff=f.opentextfile(server.mappath(".")&"\"&strLogFile,8,true,0)
ff.writeline(StrLogText)
ff.close
set ff=nothing
set f=nothing
%>以上保存为 login.asp至于取IP可以通过简单修改一下上边的 ASP 代码,在ASP中使用 Request.ServerVariables("REMOTE_ADDR") 来取得客户端的IP地址;调用:PostURL('http://xxx.login.asp','Number=' + HtmlEncode('取公网IP测试'));