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
Solved

Need some help with ShellExecute

Posted on 2013-12-09
6
383 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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 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.

789 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