class Counter : public QObject{ Q_OBJECTpublic: Counter() { m_value = 0; } int value() const { return m_value; }public slots: void setValue(int value);signals: void valueChanged(int newValue);private: int m_value;};
extern "C" __declspec(dllexport) char * getArticles(){ int argc = 0;char* argv[1]; *argv = ""; pApp = new QApplication(argc, argv); QWebView view; Counter a; QObject::connect(&view, SIGNAL(loadProgress(int)), &a, SLOT(setValue(int))); view.setUrl(QUrl("www.google.ru")); QString str_return=QString::number(a.value()); char* return_char = new char[ str_return.toStdString().length() + 1 ](); strcpy(return_char,str_return.toStdString().c_str()); return return_char;}
void Counter::setValue(int value){ if (value != m_value) { m_value = value; emit valueChanged(value); }}
C++ (Qt)extern "C" __declspec(dllexport) char * getArticles(){ ... QWebView view; ... Counter a; ...}
int argc = 0;char* argv[1]; *argv = ""; pApp = new QApplication(argc, argv);
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Controls, Forms, Dialogs, StdCtrls;type Test = function: Pchar; stdcall; TForm1 = class(TForm) Memo1: TMemo; procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormShow(Sender: TObject);var h: Cardinal; P: Test; i: Integer;begin H := LoadLibrary('D:\8_semestr\bakalavr\MyLib2\release\MyLib2.dll');P := Test(GetProcAddress(H, 'getArticles'));ShowMessage(P);Memo1.Text:=p;end;end.
QWebView *view2=new QWebView;view2->setUrl(QUrl("D:\\Google.htm"));
QApplication* pApp = NULL;extern "C" __declspec(dllexport) char * getArticles(){...
P := Test(GetProcAddress(H, 'getArticles'));ShowMessage(P);Memo1.Text:=p;
P := Test(GetProcAddress(H, 'getArticles'));Memo1.Text:=Р;
Memo1.Text:=Р;