[
板情報
|
カテゴリランキング
]
したらばTOP
■掲示板に戻る■
全部
1-100
最新50
|
メール
|
1-
101-
201-
301-
401-
501-
601-
701-
801-
901-
1001-
1101-
1201-
1301-
1401-
1501-
1601-
1701-
1801-
1901-
2001-
2101-
2201-
2301-
2401-
2501-
2601-
2701-
2801-
2901-
3001-
3101-
3201-
3301-
3401-
3501-
3601-
3701-
3801-
3901-
4001-
4101-
4201-
4301-
4401-
4501-
4601-
4701-
4801-
4901-
5001-
5101-
5201-
5301-
5401-
この機能を使うにはJavaScriptを有効にしてください
|
管理人の独り言(プログラミング関連)
1627
:
◆adhRKFl5jU
:2009/03/12(木) 12:50:42
#include "DownloadManager.hpp"
#include <string>
#include <map>
#include <windows.h>
/*----------*/
unsigned int
DownloadManager::WaitThread(void *){
return 0;
}
/*==========*/
DownloadManager::DownloadManager(const char *hash)
: m_hash(hash), m_hRunning(NULL), m_hPipe(NULL), m_hFlag(NULL)
{}
/*==========*/
bool
DownloadManager::AddPID(DWORD pid){
std::map<DWORD, HANDLE>::const_iterator it = m_pis.find(pid);
if(it == m_pis.end()){
HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, pid);
if(hProcess != NULL){
m_pis.insert(std::make_pair(pid, hProcess));
return true;
}
return false;
}
return true;
}
/*==========*/
bool
DownloadManager::Initialize(){
m_hRunning = CreateMutexA(NULL, FALSE, ("DLRunning:" + m_hash).c_str());
if(m_hRunning == NULL){
return false;
}
WaitForSingleObject(m_hRunning, INFINITE);
m_hPipe = CreateNamedPipeA(("\\\\.\\pipe\\" + m_hash).c_str(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, 0, 0, 1000, NULL);
if(m_hPipe == INVALID_HANDLE_VALUE){
ReleaseMutex(m_hRunning);
CloseHandle(m_hRunning);
return false;
}
m_hFlag = CreateEventA(NULL, TRUE, FALSE, ("DLFlag:" + m_hash).c_str());
if(m_hFlag == NULL){
CloseHandle(m_hPipe);
ReleaseMutex(m_hRunning);
CloseHandle(m_hRunning);
return false;
}
HANDLE hCreated = OpenEventA(EVENT_MODIFY_STATE, FALSE, ("DLCreated:" + m_hash).c_str());
if(hCreated == NULL){
CloseHandle(m_hFlag);
CloseHandle(m_hPipe);
ReleaseMutex(m_hRunning);
CloseHandle(m_hRunning);
return false;
}
if(SetEvent(hCreated) == FALSE){
CloseHandle(hCreated);
CloseHandle(m_hFlag);
CloseHandle(m_hPipe);
ReleaseMutex(m_hRunning);
CloseHandle(m_hRunning);
return false;
}
CloseHandle(hCreated);
return true;
}
/*==========*/
int
DownloadManager::Loop(){
return 0;
}
/*==========*/
bool
DownloadManager::Finalize(){
CloseHandle(m_hPipe);
ReleaseMutex(m_hRunning);
CloseHandle(m_hRunning);
return true;
}
新着レスの表示
名前:
E-mail
(省略可)
:
※書き込む際の注意事項は
こちら
※画像アップローダーは
こちら
(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)
スマートフォン版
掲示板管理者へ連絡
無料レンタル掲示板