Добро пожаловать! Это — архивная версия форумов на «Хакер.Ru». Она работает в режиме read-only.
 

C++ OleObject заполнение форм

Пользователи, просматривающие топик: none

Зашли как: Guest
Все форумы >> [Компилируемые языки] >> C++ OleObject заполнение форм
Имя
Сообщение << Старые топики   Новые топики >>
C++ OleObject заполнение форм - 2009-03-14 01:14:44.960000   
Lupu

Сообщений: 12
Оценки: 0
Присоединился: 2008-07-15 21:47:22.653333
Как в С++ автоматически заполнять формы php страницы?
я нашел код на Delphi но никак не могу перевести его на С++
Var &nbsp;&nbsp;&nbsp; A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; Variant; begin &nbsp;&nbsp;&nbsp; A:= WebBrowser1.OleObject.Document.getElementById('UserName'); // Поле для ввода имени пользователя &nbsp;&nbsp;&nbsp; A.Value:= Edit1.Text; &nbsp;&nbsp;&nbsp; A:= WebBrowser1.OleObject.Document.getElementById('PassWord'); // Поле для ввода пароля &nbsp;&nbsp;&nbsp; A.Value:= Edit2.Text; &nbsp;&nbsp;&nbsp; A:= WebBrowser1.OleObject.Document.getElementById('submit'); // Ну и кнопочка для входа &nbsp;&nbsp;&nbsp; A.Click; end;
Post #: 1
RE: C++ OleObject заполнение форм - 2009-03-14 02:33:42.533333   
_SaZ_

Сообщений: 4329
Оценки: 398
Присоединился: 2008-01-30 02:18:05.553333
Лол. Откуда на C++ взяться компоненту WebBrowser. Разве что в MC++ :D.
Post #: 2
RE: C++ OleObject заполнение форм - 2009-03-14 10:24:48.353333   
Lupu

Сообщений: 12
Оценки: 0
Присоединился: 2008-07-15 21:47:22.653333
Есть же TCppWebBrowser в С++ Builder
я нашол обращение к Document на С++ выглядит примерно так
A=CppWebBrowser1-&gt;OleObject.OlePropertyGet("document"); а вот как дальше делать я не нашол способа.. как найти форму и заполнить ее?
Post #: 3
RE: C++ OleObject заполнение форм - 2009-03-14 14:47:24.836666   
_SaZ_

Сообщений: 4329
Оценки: 398
Присоединился: 2008-01-30 02:18:05.553333
Понимаешь. Много теории по OLE придётся объяснять. Попробуй что-нибудь попроще. Или напиши .dll на дэлфи и прикрути её к с++.

P.S. Если пишешь на С++ Builder - то там должны быть компоненты.
Post #: 4
RE: C++ OleObject заполнение форм - 2009-03-14 15:31:17.676666   
SkyLinE215

Сообщений: -986
Оценки: 0
Присоединился: 2007-08-27 10:25:44.570000
вот нарыл тебе код
void __fastcall TFMain::bUploadClick(TObject *Sender) { &nbsp; AnsiString slHtmlFormName = "UploadForm"; // &lt;form name="UploadForm"... &nbsp; IHTMLDocument2 *pHTMLDocument = NULL; &nbsp; if(SUCCEEDED(CppWebBrowser-&gt;Document-&gt;QueryInterface( &nbsp; IID_IHTMLDocument2, (LPVOID*)&amp;pHTMLDocument))) { &nbsp; &nbsp;if(pHTMLDocument != NULL) { &nbsp; IHTMLElementCollection *pAll = NULL; &nbsp; if(SUCCEEDED(pHTMLDocument-&gt;get_all(&amp;pAll)) &amp;&amp; pAll) &nbsp; { &nbsp; &nbsp; TVariant vName="userfile", vName2 = "passwd", vName0 = "MAX_FILE_SIZE"; &nbsp; &nbsp; TVariant vIndex=0; &nbsp; &nbsp; // put into hidden field &lt;hidden... &nbsp; &nbsp; IDispatch *pDisp0=NULL; &nbsp; &nbsp; &nbsp;if(SUCCEEDED(pAll-&gt;item(vName0, vIndex, &amp;pDisp0)) &amp;&amp; pDisp0) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp;IHTMLInputHiddenElement *pSize = NULL; &nbsp; &nbsp; &nbsp; &nbsp;if(SUCCEEDED(pDisp0-&gt;QueryInterface(IID_IHTMLInputHiddenElement, &nbsp; &nbsp; &nbsp; &nbsp; (LPVOID*)&amp;pSize)) &amp;&amp; pSize) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; pSize-&gt;put_value(WideString("150000")); &nbsp; &nbsp; &nbsp; &nbsp; pSize-&gt;Release(); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; pDisp0-&gt;Release(); &nbsp; &nbsp; } &nbsp; &nbsp; // paste into file field &lt;file... &nbsp; &nbsp; IDispatch *pDisp=NULL; &nbsp; &nbsp; if(SUCCEEDED(pAll-&gt;item(vName, vIndex, &amp;pDisp)) &amp;&amp; pDisp) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; IHTMLInputFileElement* pFile = NULL; &nbsp; &nbsp; &nbsp; &nbsp;if(SUCCEEDED(pDisp-&gt;QueryInterface(IID_IHTMLInputFileElement, &nbsp; &nbsp; &nbsp; &nbsp; (LPVOID*)&amp;pFile)) &amp;&amp; pFile) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; // Copy Full FileName To Clipboard &nbsp; &nbsp; &nbsp; Clipboard()-&gt;SetTextBuf(sFile.c_str()); &nbsp; &nbsp; &nbsp; pFile-&gt;select(); &nbsp; &nbsp; &nbsp; // Paste from ClipBoard to "userfile" &nbsp; &nbsp; &nbsp; CppWebBrowser-&gt;ControlInterface-&gt;ExecWB(Shdocvw_tlb::OLECMDID_PASTE, &nbsp; &nbsp; &nbsp; Shdocvw_tlb::OLECMDEXECOPT_DODEFAULT, Variant("userfile")); &nbsp; &nbsp; &nbsp; pFile-&gt;Release(); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; pDisp-&gt;Release(); &nbsp; &nbsp; } &nbsp; &nbsp; // put into input element &lt;input... &nbsp; &nbsp; IDispatch *pDisp2=NULL; &nbsp; &nbsp; &nbsp;if(SUCCEEDED(pAll-&gt;item(vName2, vIndex, &amp;pDisp2)) &amp;&amp; pDisp2) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp;IHTMLInputElement *pInput = NULL; &nbsp; &nbsp; &nbsp; &nbsp;if(SUCCEEDED(pDisp2-&gt;QueryInterface(IID_IHTMLInputElement, &nbsp; &nbsp; &nbsp; &nbsp; (LPVOID*)&amp;pInput)) &amp;&amp; pInput) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; pInput-&gt;put_value(WideString("if5edU7dk4")); &nbsp; &nbsp; &nbsp; &nbsp; pInput-&gt;Release(); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; pDisp2-&gt;Release(); &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp;pAll-&gt;Release(); &nbsp; } &nbsp; &nbsp; // click SUBMIT() &nbsp; &nbsp; IHTMLElementCollection *HTMLForms = NULL; &nbsp; &nbsp; if(SUCCEEDED(pHTMLDocument-&gt;get_forms(&amp;HTMLForms)) &amp;&amp; HTMLForms) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; // &nbsp;slHtmlFormName &lt;form name="UploadForm"...&gt; &nbsp; &nbsp; &nbsp; TVariant vName3 = slHtmlFormName; &nbsp; &nbsp; &nbsp; TVariant vIndex3 = 0; &nbsp; &nbsp; &nbsp; IDispatch *pDisp3 = NULL; &nbsp; &nbsp; &nbsp; if(SUCCEEDED(HTMLForms-&gt;item(vName3, vIndex3, &amp;pDisp3)) &amp;&amp; pDisp3) &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; IHTMLFormElement *HTMLForm = NULL; &nbsp; &nbsp; &nbsp; &nbsp; if(SUCCEEDED(pDisp3-&gt;QueryInterface(IID_IHTMLFormElement, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (LPVOID*)&amp;HTMLForm)) &amp;&amp; HTMLForm) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HTMLForm-&gt;submit(); // нажимаем кнопку submit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HTMLForm-&gt;Release(); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; pDisp3-&gt;Release(); &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; HTMLForms-&gt;Release(); &nbsp; &nbsp; } pHTMLDocument-&gt;Release(); } } Если хоть немного OLE понимаешь, сам разберешся в коде и будешь менять его по своему вкусу..
Post #: 5
Страниц:  [1]
Все форумы >> [Компилируемые языки] >> C++ OleObject заполнение форм







Связаться:
Вопросы по сайту / xakep@glc.ru

Предупреждение: использование полученных знаний в противозаконных целях преследуется по закону.