私が取り組んでいる学校のプロジェクトがあり、その結果は無意味に思えますが、これを通じて得られた経験と関係があると私は信じています. 私がやろうとしているのは、最初の URL を送信し、そのページのすべての URL をプルして順番にアクセスし、停止するように指示されるまでこれを行うことです。すべての URL がテキスト ファイルに記録されます。これまでのところ、IE でウィンドウを開いて、選択した Web ページを起動できます。そのため、同じセッションを使用して IE を新しい Web ページに送信する方法と、アクセスした Web サイトからデータをスキャンしてプルする方法を知る必要があります。助けてくれてありがとう!
これまでの私のコードは次のとおりです。
#include <string>
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
using namespace std;
int main( int argc, TCHAR *argv[] )
{
std::string uRL, prog;
int length, count;
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
//if( argc != 2 )
//{
// printf("Usage: %s [cmdline]\n", argv[0]);
// system("PAUSE");
// return 0;
//}
std::cout << "Enter URL: ";
std::cin >> uRL;
prog = ("C:\\Program Files\\Internet Explorer\\iexplore.exe ") + uRL;
char *cstr = new char[prog.length() + 1];
strcpy(cstr, prog.c_str());
// Start the child process.
if( !CreateProcess(NULL, // No module name (use command line)
_T(cstr), // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
system("PAUSE");
return 0;
}
cout << HRESULT get_Count(long *Count) << endl;
//cout << count << endl;
system("PAUSE");
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
delete [] cstr;
return 0;
}