// SS.cpp : 定義主控台應用程式的進入點。 // #include " stdafx.h " #include < stdio.h > #include < WINSOCK2.H > #include < Windows.h > #include " winsock.h " #include " wininet.h " #pragma comment(lib,"wsock32.lib") #pragma comment(lib,"wininet.lib") #define URL_PRE "http: // cn.finance.yahoo.com/q/o?s=" #define BUF_MAX (1024 * 128) static TCHAR szBuffer[BUF_MAX] = ... {0} ; int _tmain( int argc, _TCHAR * argv[]) ... { //目標URL TCHAR szTargetURL[256] = ...{0}; //股票代碼 UINT StockCode = 600036; //股票代碼(字符串) TCHAR szStockCode[7] = ...{0}; /**//*strcpy*/wcscpy(szTargetURL, LPCWSTR(URL_PRE)); /**//*sprintf*/swprintf(szStockCode, L"%d", StockCode); //合成 /**//*szTargetURL = *//**//*strcat*/wcscat(szTargetURL, szStockCode); /**//*szTargetURL = *//**//*strcat*/wcscat(szTargetURL, L".SS"); wprintf(L"szTargetURL=%s ", szTargetURL); //網路取時 HINTERNET hNet = ::InternetOpen(L"MSDN SurfBear", PRE_CONFIG_INTERNET_ACCESS, NULL, INTERNET_INVALID_PORT_NUMBER, 0) ; HINTERNET hUrlFile = ::InternetOpenUrl(hNet, /**//*szTargetURL*/L"http://cn.finance.yahoo.com/q/o?s=600036.SS", NULL, 0, INTERNET_FLAG_RELOAD, 0); DWORD dwBytesRead = 0; BOOL bRead = ::InternetReadFile(hUrlFile, szBuffer, sizeof(szBuffer), &dwBytesRead); wprintf(L"Done! "); ::InternetCloseHandle(hUrlFile); ::InternetCloseHandle(hNet); wprintf(L"%s ", szBuffer); return 0;}