Solved

Need some help with ShellExecute

Posted on 2013-12-09
6
379 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 30

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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 30

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

705 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

13 Experts available now in Live!

Get 1:1 Help Now