Solved

Need some help with ShellExecute

Posted on 2013-12-09
6
384 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 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
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!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

733 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