龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > C/C++开发 >

从当前的浏览器取得当前URL

时间:2009-12-22 15:42来源:未知 作者:admin 点击:
分享到:
我在www.playicq.com看了一篇同名的文章,是用Delphi写的。试了以后效果还行,主要是利用了TDdeClientConv,于是改成CB版的贴出来。蓝色字符为手动添加的。 Unit1.Cpp //----------------------------

  我在www.playicq.com看了一篇同名的文章,是用Delphi写的。试了以后效果还行,主要是利用了TDdeClientConv,于是改成CB版的贴出来。蓝色字符为手动添加的。

  

  

Unit1.Cpp

  

//---------------------------------------------------------------------------

  

  

#include

  

#pragma hdrstop

  

  

#include "Unit1.h"

  

//---------------------------------------------------------------------------

  

#pragma package(smart_init)

  

#pragma resource "*.dfm"

  

TForm1 *Form1;

  

//---------------------------------------------------------------------------

  

__fastcall TForm1::TForm1(Tcomponent* Owner)

  

: Tform(Owner)

  

{

  

}

  

//---------------------------------------------------------------------------

  

String TForm1::Get_URL(AnsiString Servicio)

  

{

  

TDdeClientConv *Cliente_DDE=new TDdeClientConv(NULL);

  

char *temp;

  

Cliente_DDE->SetLink(Servicio,"WWW_GetWindowInfo");

  

temp=Cliente_DDE->RequestData("0xFFFFFFFF");

  

Cliente_DDE->CloseLink();

  

delete Cliente_DDE;

  

return String(temp);

  

}

  

//---------------------------------------------------------------------------

  

void __fastcall TForm1::Button1Click(Tobject *Sender)

  

{

  

ShowMessage(Get_URL("IeXPlore"));

  

}

  

//---------------------------------------------------------------------------

  

  

Unit1.H

  

//---------------------------------------------------------------------------

  

  

#ifndef Unit1H

  

#define Unit1H

  

//---------------------------------------------------------------------------

  

#include

  

#include

  

#include

  

#include

  

#include "ddeman.hpp"

  

//---------------------------------------------------------------------------

  

class TForm1 : public Tform

  

{

  

__published: // IDE-managed Components

  

Tbutton *Button1;

  

void __fastcall Button1Click(Tobject *Sender);

  

private: // User declarations

  

String

TForm1::Get_URL(AnsiString Servicio);

  

public: // User declarations

  

__fastcall TForm1(Tcomponent* Owner);

  

};

  

//---------------------------------------------------------------------------

  

extern PACKAGE TForm1 *Form1;

  

//---------------------------------------------------------------------------

  

#endif

right">(出处:清风软件下载学院)

  

精彩图集

赞助商链接