Solved

Need some help with ShellExecute

Posted on 2013-12-09
6
380 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
  • 4
  • 2
6 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now