C++/CLI:获取股票价格

发布于 2024-11-29 16:00:47 字数 281 浏览 1 评论 0原文

我目前正在开发一个 C++ 项目来获取我的股票价格,并将其显示在我的计算机屏幕上的单元格中。然而,我的谷歌搜索对这些都不起作用。我也搜索过图书馆,但没有结果。谁能告诉我我该怎么做?我不知道如何使用 Google 和 Yahoo API,所以也许他们需要一些帮助。我需要一些东西,这样我就可以输入我的代码,例如:

this->label1->Text = stockPrice;

主要是获取我的股票的实时价格并将其显示在我的计算机中的单元格或图表。

所以,谢谢!

I'm currently working on a C++ project to get the price of my stocks, and display it in cells on my computer screen. However, my Googling is NOT working for any of this. I also searched for libraries, but to no avail. Can anyone please tell me how I can do this? I don't know how to use the Google and Yahoo APIs, so maybe they could use some help. I need something so I can put in my code, like:

this->label1->Text = stockPrice;

The main thing about this is to get the live prices of my stocks and display it on my computer in cells or graphs.

So, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

≈。彩虹 2024-12-06 16:00:47

我怀疑这样的问题会被否决,因为它们相当重复。不过,对于刚接触 C++/CLI 的人来说,查看工作示例代码还是很有帮助的。在下面的示例中,我们使用 Yahoo 服务 - 仔细查看 URL 并找出答案,否则在网络上搜索更多有趣的内容,以学习如何使用他们的 API:)

#include "stdafx.h"

using namespace System;
using namespace System::IO;
using namespace System::Net;
using namespace System::Text;

int main(array<System::String ^> ^args)
{
    HttpWebRequest^ myRequest = dynamic_cast<HttpWebRequest^>(WebRequest::Create( "http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=1&b=1&c=2011&d=1&e=1&f=2011&g=d&ignore=.csv" ));

    myRequest->Method = "GET";
    WebResponse^ myResponse = myRequest->GetResponse();

    Stream^ receiveStream = myResponse->GetResponseStream();
    StreamReader^ sr = gcnew StreamReader( receiveStream,Encoding::UTF8 );

    Console::WriteLine(sr->ReadToEnd());

    sr->Close();
    myResponse->Close();

    return 0;
}

I suspect questions like this get voted down because they're rather repetitious. Still, for someone new to C++/CLI it's helpful to see working example code. In the example below we're using the Yahoo service--look at the URL closely and figure it out, otherwise search the web for further fun an profit to learn how to use their API:)

#include "stdafx.h"

using namespace System;
using namespace System::IO;
using namespace System::Net;
using namespace System::Text;

int main(array<System::String ^> ^args)
{
    HttpWebRequest^ myRequest = dynamic_cast<HttpWebRequest^>(WebRequest::Create( "http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=1&b=1&c=2011&d=1&e=1&f=2011&g=d&ignore=.csv" ));

    myRequest->Method = "GET";
    WebResponse^ myResponse = myRequest->GetResponse();

    Stream^ receiveStream = myResponse->GetResponseStream();
    StreamReader^ sr = gcnew StreamReader( receiveStream,Encoding::UTF8 );

    Console::WriteLine(sr->ReadToEnd());

    sr->Close();
    myResponse->Close();

    return 0;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文