-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnectThread.cpp
105 lines (91 loc) · 2.73 KB
/
ConnectThread.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ConnectThread.h"
#include "CacheThread.h"
#include "vdskapi.h"
#include "main.h"
#include <vector>
#include "functions.h"
#pragma package(smart_init)
#include <algorithm>
#include <string.h>
#include <vector>
#include "dumpthread.h"
#include "cachethread.h"
#include "MakeFATThread.h"
#include <windows.h>
#include <Winsock2.h>
using namespace std;
extern ULONG totcachsize;
extern vector<CACHE>cache;
extern TCriticalSection *ccs;
extern TEvent *cev;
extern int unsaved;
extern TCriticalSection *cchs;
extern double disksize;
extern LPVOID memory;
extern HANDLE hdisk;
#pragma package(smart_init)
// ---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(&UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall ConnectThread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
// ---------------------------------------------------------------------------
__fastcall ConnectThread::ConnectThread(bool CreateSuspended):TThread(CreateSuspended)
{
}
// ---------------------------------------------------------------------------
void __fastcall ConnectThread::Execute()
{
NameThreadForDebugging("ConnectThread");
// ---- Place thread code here ----
LARGE_INTEGER xyu;
// deb("ïîäêëþ÷àåìñÿ ...");
xyu.QuadPart = 0;
// paintdisk(2, xyu, 10, false);
// paintdisk(4, xyu, 10, false);
// Form1->deblog->Clear();
if (!disksize)
disksize = 100*1024*1024*1024;
// deb("disksize = %.0f (%.0f MB)", disksize, disksize/1024/1024);
extern SOCKET ConnectSocket;
extern bool ramdisk;
shutdown(ConnectSocket, SD_BOTH);
closesocket(ConnectSocket);
ConnectSocket = NULL;
if (!ramdisk&&!nconn())
{
deb("îøèáêà ñîåäèíåíèÿ ñ ñåðâåðîì.");
return;
}
// if (!memory && disksize)
// {
// memory = (LPVOID)new char[disksize];
// if (!memory)
// {
// deb("failed to alloc %d bytes of memory for disk", disksize);
// return;
// }
// deb(" âûäåëåíî %.0f áàéò (%.0f MB) äëÿ äèñêà @ 0x%08p",disksize,
// disksize/1024/1024, memory);
// }
// DWORD dwId;
// CreateThread(NULL, 0, makefatdisk, NULL, NULL, &dwId);
//
// MakeFAT *x;
// x = new MakeFAT(false);
// prefetch();
Form1->Button1->Enabled = false;
// ShellExecute(NULL, "open", "y:\\", NULL, NULL, SW_SHOW);
Form1->makefatdisk(NULL);
}
// ---------------------------------------------------------------------------