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
// 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
相关文章推荐
- java 执行命令、调用bat文件、调用外部程序的两种方法
- C # 调用外部程序方法
- flex air应用程序在windows环境下调用外部exe程序的一种方法
- PHP调用外部程序的方法
- PHP程序调用java类的两种方法
- C# Shell 调用外部程序方法
- VC中调用外部EXE程序方法
- Android Camera 使用小结。两种方法:一是调用系统camera app,二是自己写camera程序。
- QT调用外部程序有下面几种方法:
- java调用外部程序的方法
- Shark中调用外部程序的方法
- VC中调用外部EXE程序方法(转)
- system调用外部程序的方法
- SilverLight浏览器交互之:SilverLight程序调用外部Html中的Javascript方法(附源码)
- QT中调用外部程序的方法 QProcess类
- QT中调用外部程序的方法 QProcess类
- Qt打开外部程序的三种方法(两种阻塞,一种不阻塞)
- Android中外部程序activity调用本地程序的app方法。
- linux C程序调用外部程序的几种方法
- C/C++项目调用外部exe程序方法