My Qt app needs to invoke a function with arguments from my owned dll, which was created with VS2010.
It runs as expected if the imported function without any argument.
But with arguments it will crash, although there is no problem when compiling.
Any advise will be helpful!
Thanks.
//.pro
LIBS += -L ./ -lop
LIBS += -L ./ -lop
To copy to clipboard, switch view to plain text mode
//op.h
#ifndef OP_H
#define OP_H
#include <string>
extern "C" __declspec(dllexport) void excute(std::wstring url);
#endif // OP_H
#ifndef OP_H
#define OP_H
#include <string>
extern "C" __declspec(dllexport) void excute(std::wstring url);
#endif // OP_H
To copy to clipboard, switch view to plain text mode
//invoke code
std::wstring url=qstr_url.toStdWString();
excute(url);
std::wstring url=qstr_url.toStdWString();
excute(url);
To copy to clipboard, switch view to plain text mode
//dll in vs2010
// op.cpp
#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://google.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);
}
#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://google.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);
}
To copy to clipboard, switch view to plain text mode
Bookmarks