16,203
社区成员
发帖
与我相关
我的任务
分享
LIBS += -L ./ -lop
#ifndef OP_H
#define OP_H
#include <string>
extern "C" __declspec(dllexport) void excute(std::wstring url);
#endif // OP_H
std::wstring url=qstr_url.toStdWString();
excute(url);
#include "stdafx.h"
extern "C" __declspec(dllexport) void excute(std::wstring url )
{
STARTUPINFO start_info;
PROCESS_INFORMATION proc_info;
::ZeroMemory(&start_info, sizeof(start_info));
start_info.cb = sizeof(start_info);
::ZeroMemory(&proc_info, sizeof(proc_info));
std::wstring browser = L"C:/Program Files/Internet Explorer/iexplore.exe";
//std::wstring url = L"http://china.com";
std::wstring command = browser + L" " + url;
LPWSTR command_line = new WCHAR[command.size() + 1];
wcscpy_s(command_line, command.size() + 1, command.c_str());
command_line[command.size()] = L'\0';
::CreateProcess(NULL, command_line, NULL, NULL, FALSE, 0, NULL, NULL, &start_info, &proc_info);
if (proc_info.hThread != NULL) {
::CloseHandle(proc_info.hThread);
}
if (proc_info.hProcess != NULL) {
::CloseHandle(proc_info.hProcess);
}
#ifndef OP_H
#define OP_H
#include <string>
extern "C" __declspec(dllexport)__stdcall void excute(std::wstring url);
#endif // OP_H