?
Solved

Need some help with ShellExecute

Posted on 2013-12-09
6
Medium Priority
?
390 Views
Last Modified: 2013-12-09
Hello,
with yahoo finance you can get a lot of data from stocks.

Go to www.gummy-stuff.org/yahoo-data.htm

With this code: finance.yahoo.com/d/quotes.txt?s=GE&f=l1d1n in your explorer
you get 26.94,"12/6/2013","General Electric "
The latest price $ 26.94 of General Electric stock from Dec.6th, 2013

With my code below I open the internet explorer.
CString str_Internet="finance.yahoo.com/d/quotes.txt?s=GE&f=l1d1n";
ShellExecute(NULL,"open","iexplore",str_Internet,NULL,SW_NORMAL);


I would like to get the data in a Cstring without open the explorer
something like: Cstring data= ShellExecute(NULL,"open","iexplore",str_Internet,NULL,SW_NORMAL);

How can I get the data without open the explorer.

Please help….still a novice in MFC

500 poinst with a solution

Best regards,
Thomas


Visual Studio Net 2003
0
Comment
Question by:tsp2002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 2000 total points
ID: 39705612
Hi tsp2002,

IMO it's not the best idea to do this via InternetExplorer with ShellExecute, IMO you won't be able to avoid IE just displays the loaded data and I don't see a possibility to retrieve the data in your application.

I think you should implement a code to download the data directly. With MFC this is quite easy, i.e. like this:
// best is to put this include into 'stdafx.h'
#include <afxinet.h>

CString GetData( LPCTSTR pszUrl )
{
	CInternetSession session;
	CStdioFile* pResponse = NULL;

	try
	{
		pResponse = session.OpenURL( pszUrl );
	}
	catch (CInternetException* e)
	{
		// do error handling
	}
	catch (CException* e)
	{
		// do error handling
	}

	if ( NULL == pResponse )
	{
		// no repsonse
		return "";
	}

	CString strData, strLine;

	while( FALSE != pResponse->ReadString( strLine ) )
	{
		strData += strLine + "\r\n";
	}

	delete pResponse;

	return strData;
}

Open in new window

Now you can use it i.e. like this:

      AfxMessageBox( GetData( "http://finance.yahoo.com/d/quotes.txt?s=GE&f=l1d1n" ) );

to display a message box showing something like this:

      26.94,"12/6/2013","General Electric "

Hope this helps,

ZOPPO
0
 

Author Comment

by:tsp2002
ID: 39705783
Hello Zoppo,
thanks for your code. It will run without an error, but I got no data. Messagebox is empty.
I have enclosed #include <afxinet.h> in 'stdafx.h'.
What did I do wrong?
0
 

Author Comment

by:tsp2002
ID: 39705796
it will stop here

catch (CInternetException* e)
how can I get the error
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:tsp2002
ID: 39705880
Hello Zoppo,
it works.... I forgot to add http:// in the string

S O R R Y

Great work!!!
Thank you very much for your help.

Schöne Weihnachten und besten Gruß von
Thomas
0
 

Author Closing Comment

by:tsp2002
ID: 39705881
Great work, thank you for your help
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 39705899
Thanks :o) the same to you ...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question