Use c++ to access internet explorer - c++

Well as the topic says, I want to know if there is a tool or a tutorial that can help me access IE, get in a certain URL, do some action on that website. So I would have a program to do that for me instead of doing it myself every time.

Here is a project on Internet Explorer automation with C++

you should really rephrase your question.. you said what you want to do is login to hotmail programatically, check the pidgin code, they do it.
Documentation found here , here and you can I think navigate through the code and tutorials at will until you have your understanding of how the pidgin contributors did it.
You can find the main page for pidgin here
Code sample to get you started:
00362 static void
00363 msn_show_hotmail_inbox(PurplePluginAction *action)
00364 {
00365 PurpleConnection *gc;
00366 MsnSession *session;
00367
00368 gc = (PurpleConnection *) action->context;
00369 session = gc->proto_data;
00370
00371 if (session->passport_info.file == NULL)
00372 {
00373 purple_notify_error(gc, NULL,
00374 _("This Hotmail account may not be active."), NULL);
00375 return;
00376 }
00377
00378 purple_notify_uri(gc, session->passport_info.file);
00379 }
00652 void *
00653 purple_notify_uri(void *handle, const char *uri)
00654 {
00655 PurpleNotifyUiOps *ops;
00656
00657 g_return_val_if_fail(uri != NULL, NULL);
00658
00659 ops = purple_notify_get_ui_ops();
00660
00661 if (ops != NULL && ops->notify_uri != NULL) {
00662
00663 void *ui_handle = ops->notify_uri(uri);
00664
00665 if (ui_handle != NULL) {
00666
00667 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
00668 info->type = PURPLE_NOTIFY_URI;
00669 info->handle = handle;
00670 info->ui_handle = ui_handle;
00671
00672 handles = g_list_append(handles, info);
00673
00674 return info->ui_handle;
00675 }
00676 }
00677
00678 return NULL;
00679 }

Rather than using IE for such things, look into appropriate screen scraping libraries for your language of choice. You can google and search Stack Overflow to find many such libraries. From here, you'll use your language's web APIs to send data to the server.

Don't know of any tool.
I use an embedded browser for such things. It is possible to connect to a running instance of IE. See
Connect to Running Instance of IE
Once you get an instance of IWebBrowser2, the coding is the same.
1. Get the Document Interface
pWebBrowser->Document->QueryInterface(
IID_IHTMLDocument2,(LPVOID*)&Doc);
2. Get all the elements on the Document
Doc->get_all(&Elements);
3. enum the Elements
Elements->get_length(&ulLen);
for_each
Elements->item(item, index, &ppvElement);
4. Detemine what element is desired.
* by classname
* by ID etc.. here I used the classname
ppvElement->get_className (&bstrElement);
5. Insert Text for user / password
ppvElement->put_innerText(wsUreser_or_Psswd)
6. Find the Sign in button and click it.
ppvElement->Click();
Your results may vary.
--
Michael

Why don't you make a feed in dapper in two minutes? Apparently some people have already done it as well.

Related

Setting a WinRt AdvertisementFilter() to a substring of LocalName

C++, WinRT, VS2017, Win10
I create a watcher to look for my Bluetooth LE device with
BluetoothLEAdvertisementWatcher watcher;
Now I want to set a filter for for the device that I am specifically looking for. Let's say that the LocalName for the device is "MyDevice_ABC1234". I can do this with
watcher.AdvertisementFilter().Advertisement().LocalName().c_str() == L"MyDevice_ABC1234";
But what I really want to do is set the filter to the manufacture's name and not the specific model number. I want to filter for "MyDevice" being in the LocalName. This would be easy enough given the luxury of a few lines of code but how would it be done in the context of
watcher.AdvertisementFilter().Advertisement().LocalName()
LocalName() has an operator for basic_string_view which has a find() method but for the life of me I can't get that to work properly. The find() is supposed to return the npos so I tried:
watcher.AdvertisementFilter().Advertisement().LocalName().operator std::basic_string_view<wchar_t, std::char_traits<wchar_t>>.find("MyDevice") == 8;
I actually tried this as simple code so I could debug the results with
hstring hstrLocalName = L"MyDevice_aBC1234";
bool bFind = hstrLocalName.operator std::basic_string_view<wchar_t, std::char_traits<wchar_t>>.find("MyDevice", 0) == 8;
and also
int iFind = hstrLocalName.operator std::basic_string_view<wchar_t, std::char_traits<wchar_t>>.find("MyDevice", 0);
But neither of these worked. They compiled but just never executed. Is there a way to get the basic_string_view.find() to work or would there be a better way to do this?
I see now, that when I do use the method mentioned above from StackOverflow here, it does filter for the LocalName that I set. However, and I remember this warning from the docs somewhere, that some advertisement packets come with the local name but not Uuids and visa versa. As it happenes, that is why I thought the filter was catching nothing. I was ignoring any packets that did not have services and these were the ones with the LocalName. Catch22.
For what it is worth, here is the method for setting a filter mentioned in the link above that also worked for me (with caveats)
auto filter = BluetoothLEAdvertisementFilter();
auto advert = BluetoothLEAdvertisement();
advert.LocalName(L"MyDevice_ABC1234");
filter.Advertisement(advert);
watcher.AdvertisementFilter(filter);

Hosting help content online

I'm trying to package some of my MFC applications as Windows 10 apps using Desktop Bridge.
I am having no end of trouble getting my HTML help file (CHM) included and working with the installed program (new versions of VS don't include the help file, and using workaround to include that file results in a file that I don't have the rights to access).
So it makes me wonder about hosting the online help on my website. A couple of the issues that arise is how best to host multiple help topics, and how to override (on a application-wide basis) the behavior of accessing help topics. (My app is dialog-based.)
So I just wondered if anyone else has done this already. I'd be curious to review how these issues were addressed. I was not able to find anything online.
I do host my html help in a single document, using html anchors to get to the topic of interest. If you have multiple pages, adapt MyHelp accordingly.
I didn't actually use the Desktop Bridge but wondered if you have tried something like this:
BOOL CMyDialog::OnHelpInfo(HELPINFO* pHelpInfo)
{
MyHelp(_T("HIDD_MYDIALOG")); // HTML anchor goes here
return CDialog::OnHelpInfo(pHelpInfo);
}
...
// a global helper function for showing help
void MyHelp(LPCTSTR anchor)
{
extern CMyApp theApp;
TCHAR *cp, buffer[1000];
// look for the html document in the program directory
strcpy(buffer, _T("file:///"));
DWORD dw = GetModuleFileName(theApp.m_hInstance, buffer + strlen(buffer), sizeof(buffer));
if (cp = strrchr(buffer, '\\'))
{
strcpy(cp+1, _T("MyHelpDocument.htm#"));
strcat(cp+1, anchor);
// for some reason, I don't want the default browser to open, just the Internet Explorer
ShellExecute(NULL, _T("open"), _T("iexplore"), buffer, NULL, SW_SHOWNORMAL);
// or, for real online help, use just '_T("http://myurl.com/myonlinehelpdocument.html#") + anchor'
// instead of 'buffer' and ommit all before ShellExecute()
}
}
I'm not sure if ShellExecute will behave the way it used to in the shop app though. But certainly there will be a way to open a URL somehow. You might want to try if the Internet Explorer ActiveX works to display your help pages inside the app.

OpenLDAP API Search

I'm attempting to do an LDAP search using the OpenLDAP API. I've already successfully connected and bound to the server. I've done the search with ldap_search_ext_s() and parsed the result with ldap_parse_result(). However, I can't seem to figure out how to get the actual results of the search. Unfortunately, the OpenLDAP C API has changed recently and many of the existing examples on the Internet do not use the current API.
I've already attempted to use ldap_first_attribute(), ldap_next_attribute(), and ldap_get_values() as shown on http://www-archive.mozilla.org/directory/csdk-docs/search.htm (Example 6-13). However, it appears that ldap_get_values() is now deprecated and that ldap_get_values_len() is the closest replacement. Instead of returning a char**, the new function returns a berval**. I've attempted to tweak this example code by creating a berval* with the value of barval**[i]. This results in a successful compile, but a core dump at ber_scanf().
Does anyone know how to get the results of an LDAP search with the OpenLDAP C API?
UPDATE:
In particular, I'm asking how to get the attributes requested from the search message.
The result of a search request always contains a series of SearchResultEntry or SeachResultReference messages, this series terminated by a SearchResultDone message. Calling getNextAttribute (in any language and in any API) makes no sense whatever because the search results are a list of messages. An API should package the array of entries or references in such a way wherein the caller can simply retrieve the list of entries or references. Look for a method that does that.
After taking a look at the OpenLDAP API source code and seeing how the berval value was used, I eventually stumbled upon how to get it's value.
First, you have to get the first entry with ldap_first_entry(). Then, you need to get the first attribute in that entry with ldap_first_attribute(). Then, put the values in a berval** array with ldap_get_values_len(). The returned attribute values can then be access with berval[i]->bv_val.
You can get the next entries and attributes with ldap_next_entry() and ldap_next_attribute(), respectively.
I hope this helps anyone who has a similar issue.
hope the bellow function may help you,
int ldap_search_result(LDAP *ld, char *search_filter, char *search_base)
{
LDAPMessage *result;
BerElement *ber;
char *attr;
char **val;
if(ldap_search_ext_s(ld, search_base, LDAP_SCOPE_CHILDREN,
search_filter, NULL, 0, NULL, NULL, NULL, -1, &result) != LDAP_SUCCESS) {
return -1;
}
if(ldap_count_entries(ld,result) != 1) { // assuming search_filter is unique,
// matches only one entry, and so
// search routine returns only one entry
return -1;
}
if((attr = ldap_first_attribute(ldp, result, &ber)) == NULL) {
return -1;
}
do {
if((val = ldap_get_values(ldp,result,attr)) == NULL) {
return -1;
}
printf(" %s : %s \n", attr, val[0]); // assuming all attributes are single -
//valued.
ldap_memfree(attr);
ldap_value_free(val);
while((attr = ldap_next_attribute(ld,result,ber)) != NULL);
return 0;
}

Where can Sitecore webcontrol examples be found?

I've been looking over the Sitecore documentation for HtmlControls and WebControls, but none of the items have any meaningful descriptions or example code to show how they're used or what they produce.
I understand how to use simple controls like Text, Date, Image, and Link:
<sc:Text runat="server" ID="content" Field="Content" />
Is there a resource that includes examples for more advanced controls like WebControls.ItemList or HtmlControls.TreePicker to show how they'd be used and what output they produce?
The SDN has some code examples. Essentially, WebControls are .NET server controls where you write all business logic and front-end code via C#. Here's the series on the SDN called "Web Controls":
Part 1
Part 2
Part 3
Here's a sample TextControl:
protected override void DoRender(HtmlTextWriter output) {
if (ClassAttribute.Length > 0) {
output.AddAttribute(HtmlTextWriterAttribute.Class, ClassAttribute);
}
if (StyleAttribute.Length > 0) {
output.AddAttribute(HtmlTextWriterAttribute.Style, StyleAttribute);
}
output.RenderBeginTag(HtmlTextWriterTag.Div);
string val = string.Empty;
if(_text.Length == 0) {
val = GetFieldValue(_textField);
} else {
val = _text;
}
output.AddAttribute(HtmlTextWriterAttribute.Class, TextClass);
output.AddAttribute(HtmlTextWriterAttribute.Style, TextStyle);
output.RenderBeginTag(HtmlTextWriterTag.Div);
output.Write(val);
output.RenderEndTag();
output.RenderEndTag();
}
EDIT: To understand how internal built-in Sitecore components work:
Sitecore is not going to provide the details of how their controls are built. Sitecore is not open source. That being said, I've been told several times by people from Sitecore that if you need to understand how something works to extend it, use the .NET Reflector to de-compile the kernel (Sitecore.Kernel.dll). I've done this many times to figure out how the internal things work. In your case, you can decompile the assembly and look at the classes under Sitecore.Web.UI.WebControls etc.

what is the media player uid in symbian^3 (N8 device)

in my application,i just wanna open a url contain media,e.g. http://www.test.com/test.mp3,or rstp://www.test.com/test.3gp,so i need the symbian embeded media player's uid to open it.
This is what I use for showing links:
_LIT( KTestUrlPrefix,"4 " );
HBufC* parameter = HBufC::NewLC( KTestUrlPrefix().Length() + aLink.Length() );
parameter->Des().Copy( KTestUrlPrefix );
parameter->Des().Append( aLink );
if(iLauncher)
{
delete iLauncher;
iLauncher = NULL;
}
iLauncher = CBrowserLauncher::NewL();
iLauncher->LaunchBrowserEmbeddedL( *parameter, NULL, NULL, iOverriddenSettings );
CleanupStack::PopAndDestroy();
_LOGENTRY("web ad->");
If you know the content type of the URL, you can discover the UID of the right application and launch it as detailed here.
There are other alternatives:
CVideoPlayerUtility and CAudioPlayerUtility. Both have OpenUrl() methods.
Use the streaming classes directly (CMdaAudioOutStream and friends)
.. and there are other methods too.
That all said, if you are targeting Symbian^3 onwards, you might be better off developing in QT - Symbian C++ can very much considered 'deprecated' for app development.