您的位置:首页 > 其它

vc弹屏的两种方法(调用外部程序)

2010-08-17 17:02 417 查看
第一种:

// IE打开网页

void openHtml(char * sURL)

{

ShellExecute(NULL, "open", sURL, NULL, NULL, SW_SHOWNORMAL); }

第二种:

注册表中默认浏览器打开

void openHtml(char * sURL)

{

HKEY hkRoot,hSubKey; //定义注册表根关键字及子关键字

char ValueName[256];

unsigned char DataValue[256];

unsigned long cbValueName=256;

unsigned long cbDataValue=256;

char ShellChar[256]; //定义命令行

DWORD dwType;

//打开注册表根关键字

if(RegOpenKey(HKEY_CLASSES_ROOT,NULL,&hkRoot)==ERROR_SUCCESS)

{

//打开子关键字

if(RegOpenKeyEx(hkRoot,

"htmlfile//shell//open//command",

0,

KEY_ALL_ACCESS,

&hSubKey)==ERROR_SUCCESS)

{

//读取注册表,获取默认浏览器的命令行

RegEnumValue(hSubKey,

0,

ValueName,

&cbValueName,

NULL,

&dwType,

DataValue,

&cbDataValue);

// 调用参数(主页地址)赋值

strcpy_s(ShellChar,(char *)DataValue);

strcat(ShellChar,sURL);

// 启动浏览器

WinExec(ShellChar,SW_SHOW);

}

else

{

//关闭注册表

RegCloseKey(hSubKey);

RegCloseKey(hkRoot);

}

}

}

VC中调用外部程序方式总结:http://sharep.blog.51cto.com/539048/151384

Powered by Zoundry Raven
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: