网站首页 | 网页制作 | 网络编程 | 图形图象 | 冲浪宝典 | 操作系统 | 软件教学 | 网络安全 | 认证考试 | 下载中心 | 游戏下载
| 网络安全首页 | 安全在线 | 病毒防治 | 黑客攻防 | 漏洞研究 | 黑客编程 | 破解手记 |
您现在的位置: 超人气学院 >> 网络安全 >> 黑客编程 >> 文章正文 用户登录 新用户注册
在桌面建立快捷方式           
在桌面建立快捷方式
作者:未知 文章来源:网络收集 点击数: 更新时间:2006-3-29 15:22:23
Harold Howe(翻译:抱雪)

API提供了一个COM接口:调用 IShellLink 将允许你建立一个快捷方式,要在桌面建立一个快捷方式,只要把这个快捷方式保存到桌面目录就可以了。

下面的示例代码演示怎样建立一个快捷方式,在这个例子里,快捷方式将保存在C:\ drive。

//----------------------------------------------------------------------
#include

void __fastcall TForm1::Button1Click(TObject *Sender)
{
// Allow the user to find a file with a common dialog box,
// then create a shortcut to that file.
if(OpenDialog1->Execute())
CreateShortCut(OpenDialog1->FileName);
}
//----------------------------------------------------------------------
void TForm1::CreateShortCut(const AnsiString &file)
{
// IShellLink allows us to create the shortcut.
// IPersistFile saves the link to the hard drive.
IShellLink* pLink;
IPersistFile* pPersistFile;

// First, we have to initialize the COM library
if(SUCCEEDED(CoInitialize(NULL)))
{
// If CoInitialize doesn't fail, then instantiate an
// IShellLink object by calling CoCreateInstance.
if(SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER,
IID_IShellLink, (void **) &pLink)))
{
// if that succeeds, then fill in the shortcut attributes
pLink->SetPath(file.c_str());
pLink->SetDescription("Woo hoo, look at Homer's shortcut");
pLink->SetShowCmd(SW_SHOW);

// Now we need to save the shortcut to the hard drive. The
// IShellLink object also implements the IPersistFile interface.
// Get the IPersistFile part of the object using QueryInterface.
if(SUCCEEDED(pLink->QueryInterface(IID_IPersistFile,
(void **)&pPersistFile)))
{
// If that succeeds, then call the Save method of the
// IPersistFile object to write the shortcut to the desktop.
WideString strShortCutLocation("C:\\bcbshortcut.lnk");
pPersistFile->Save(strShortCutLocation.c_bstr(), TRUE);
pPersistFile->Release();
}
pLink->Release();
}

// Calls to CoInitialize ne

[1] [2] [3] 下一页

[ 收藏此页到: 天天|和讯|博采|ViVi|狐摘|我摘|天极 ] 文章录入:kinda    责任编辑:kinda 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    专 题 栏 目
    最 新 热 门
     Windows中巧用RUNDLL3[5355]
     黑客软件编写基础知识[827]
     Win32Asm快速教程[535]
    相 关 文 章
    桌面撞球
    桌面撞球算法分析
    搜易桌面邮件服务器1.3破解
    用VB编程实现任意修改Wind
    桌面工具PersonalHelperV2
    世纪葵花--桌面直播录像机
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)