Форум программистов, компьютерный форум, киберфорум
C/C++: WinAPI
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.62/13: Рейтинг темы: голосов - 13, средняя оценка - 4.62
0 / 0 / 0
Регистрация: 01.10.2013
Сообщений: 16

Файловый менеджер через winapi

23.03.2014, 22:50. Показов 2790. Ответов 4
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Вобще задали сделать файловый менеджер. Начали учить winapi недавно.

Он должен уметь следующее:
1.переместить - перемещает из одной папки в другую;
2.удалить - удаляет выделенный файл;
3.копировать - копирует из одной папки в другую.

Сделал только 2 окна, ввод пути к папкам. Могу ввести путь и мне покажет содержимое данной папки.
Помоги реализовать вышеперечисленные пункты. Не знаю даже и приблезительно с чего начать. Вот мой код.

C++
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
#include <windows.h>
#include <time.h>
#include <vector>
#include <list>
#include <random>
#include <ctime>
#include <fstream>
#include <stdio.h>
using namespace std;
 
std::random_device rd;
 
char className[] = "WindowClass1";
MSG msg;
HWND hedit, hres_edit;
HINSTANCE hInst;
 
 
double k = 1, k2 = 1000, num2 = 0;
char path[80];
char path2[80];
bool x = true;
 
list <HWND> hndls;
list <HWND>::iterator pos;
 
#define find_id     3000
#define search_id   3001
#define search_id2  3002
#define edit_id     3004
#define edit_id2    3005
#define list_id     3006
#define list_id2    3007
#define back_id     3008
#define back_id2    3009
#define delete_id   3010
HANDLE bmp;
 
 
LRESULT CALLBACK WndProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam){
    static HWND hstatic;
    static HWND hlistbox, hlistbox2;
    static HWND hbutton, hbutton2, hbutton3;
    static HWND hedit, hedit2;
 
    switch (msg){
 
    case WM_CREATE:
    {
                      //Лист 1
                      hlistbox = CreateWindow("listbox", NULL, WS_CHILD | WS_VISIBLE | LBS_WANTKEYBOARDINPUT | LBS_STANDARD,
                          20, 100, 300, 400, wnd, (HMENU)list_id, hInst, 0);
                      //Лист 2
                      hlistbox2 = CreateWindow("listbox", NULL, WS_CHILD | WS_VISIBLE | LBS_WANTKEYBOARDINPUT | LBS_STANDARD,
                          340, 100, 300, 400, wnd, (HMENU)list_id2, hInst, 0);
 
                      //Окно ввода 1
                      hedit = CreateWindow("edit", "Укажите путь 1", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
                          20, 70, 110, 20, wnd, (HMENU)edit_id, hInst, 0);
                      //Найти 1
                      hbutton = CreateWindow("button", "Найти", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          135, 70, 90, 20, wnd, (HMENU)search_id, hInst, 0);
                      //Назад
                      hbutton = CreateWindow("button", "<--", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          230, 70, 90, 20, wnd, (HMENU)back_id, hInst, 0);
 
                      //Окно воода 2
                      hedit2 = CreateWindow("edit", "Укажите путь 2", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
                          340, 70, 110, 20, wnd, (HMENU)edit_id2, hInst, 0);
                      //Найти 2
                      hbutton2 = CreateWindow("button", "Найти", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          455, 70, 90, 20, wnd, (HMENU)search_id2, hInst, 0);
                      //Назад 2
                      hbutton2 = CreateWindow("button", "<--", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          550, 70, 90, 20, wnd, (HMENU)back_id2, hInst, 0);
                      return 0;
    }
    case WM_COMMAND:
    {
                       int mes = HIWORD(wParam);
                       int buttonID = LOWORD(wParam);
 
 
                       //LB_RESETCONTENT - очищает поле
                       //LPSTR - char*
                       if ((buttonID == search_id) && (mes == BN_CLICKED)){
                           SendMessage(hlistbox, LB_RESETCONTENT, 0, 0);
                           char path[40];
                           GetWindowText(hedit, path, 40);
                           strcat(path, "*.*");
                           SendMessage(hlistbox, LB_DIR, (WPARAM)(UINT)DDL_DIRECTORY, (LPARAM)(LPSTR)path);
                       }
 
                       if ((buttonID == search_id2) && (mes == BN_CLICKED)){
                           SendMessage(hlistbox2, LB_RESETCONTENT, 0, 0);
                           char path2[40];
                           GetWindowText(hedit2, path2, 40);
                           strcat(path2, "*.*");
                           SendMessage(hlistbox2, LB_DIR, (WPARAM)(UINT)DDL_DIRECTORY, (LPARAM)(LPSTR)path2);
                       }
 
 
                       if ((buttonID == list_id2 && mes == LBN_DBLCLK) || (buttonID == find_id && mes == BN_CLICKED))
                       {
                           // LB_GETCURSEL - возвращает 
                           int n2 = (int)SendMessage(hlistbox2, LB_GETCURSEL, 0, 0), i = 0;
                           char name2[40], txt[] = "txt";
                           SendMessage(hlistbox2, LB_GETTEXT, n2, (LPARAM)name2);
                           GetWindowText(hedit2, path2, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           strcat(path2, name2);
 
                           n2 = 0;
                           SendMessage(hlistbox2, LB_RESETCONTENT, 0, 0);
                           fstream file(path2, ios::in);
                           file.seekg(0, ios::end);
                           long size2 = file.tellg();
                           file.seekg(0, ios::beg);
                           char *str = new char[size2], *str2 = new char[size2];
                           while (!file.eof()){
                               file.getline(str, size2);
                               //LB_INSERTSTRING - указывает на строку куда надо вставлять 
                               SendMessage(hlistbox2, LB_INSERTSTRING, n2++, (LPARAM)str);
                           }
                           file.close();
                       }
 
                       if ((buttonID == list_id && mes == LBN_DBLCLK) || (buttonID == find_id && mes == BN_CLICKED))
                       {
                           // LB_GETCURSEL - возвращает 
                           int n = (int)SendMessage(hlistbox, LB_GETCURSEL, 0, 0), i = 0;
                           char name[40], txt[] = "txt";
                           SendMessage(hlistbox, LB_GETTEXT, n, (LPARAM)name);
                           GetWindowText(hedit, path, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           strcat(path, name);
 
                           n = 0;
                           SendMessage(hlistbox, LB_RESETCONTENT, 0, 0);
                           fstream file(path, ios::in);
                           file.seekg(0, ios::end);
                           long size = file.tellg();
                           file.seekg(0, ios::beg);
                           char *str = new char[size], *str2 = new char[size];
                           while (!file.eof()){
                               file.getline(str, size);
                               //LB_INSERTSTRING - указывает на строку куда надо вставлять 
                               SendMessage(hlistbox, LB_INSERTSTRING, n++, (LPARAM)str);
                           }
                           file.close();
                       }
                       return 0;
    }
 
    case WM_TIMER:
    {
                     return 0;
    }
 
    case WM_DESTROY: {PostQuitMessage(0); return 0; }
    }
    return DefWindowProc(wnd, msg, wParam, lParam);
}
 
int APIENTRY WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR     lpCmdLine,
    int       nCmdShow)
{
    WNDCLASS wc;
    HWND hwnd;
 
    hInst = hInstance;
 
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(NULL, IDI_QUESTION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.lpfnWndProc = WndProc;
    wc.lpszMenuName = NULL;
    wc.hbrBackground = (HBRUSH)(3);
    wc.lpszClassName = className;
    wc.cbClsExtra = wc.cbWndExtra = wc.style = 0;
 
    int k = RegisterClass(&wc);
 
    hwnd = CreateWindow(className, "Manager", WS_VISIBLE | WS_SYSMENU | WS_MAXIMIZEBOX | WS_THICKFRAME,
        150, 150, 680, 600, NULL, NULL, hInstance, 0);
 
    if (!hwnd) return false;
 
    while (GetMessage(&msg, 0, 0, 0)){
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
 
    return 1;
}
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
23.03.2014, 22:50
Ответы с готовыми решениями:

Файловый менеджер на чистом С + WinAPI
Уважаемые форумчане) Прошу у Вас помощи в написании программы, которая должна просматривать содержимое и навигация по всем локальным...

Файловый менеджер
Здравствуйте! Не подскажете, какой компонент используется в тотал командере, для отображения файлов? &gt;&gt; нашёл ответ на свой...

Файловый менеджер
Здравствуйте, как написать файловый менеджер с такими командами: 1) Список файлов в каталоге (с возможностью сортировки) 2) Переход в...

4
27 / 27 / 10
Регистрация: 10.04.2013
Сообщений: 91
24.03.2014, 11:22
смотреть в сторону
C++
1
2
3
MoveFile
CopyFile
DeleteFile
1
 Аватар для Izual
143 / 122 / 21
Регистрация: 13.11.2012
Сообщений: 1,564
24.03.2014, 11:59
Очень интересная тема по файлам(именно по поиску файлов и каталогов): Поиск папок с помощью FindFirstFile\FindNextFile
0
0 / 0 / 0
Регистрация: 01.10.2013
Сообщений: 16
24.03.2014, 14:29  [ТС]
да, смотрю.. Вот сделал копировани, удаление и перемещение, но только текстовых файлов.

C++
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
#include <windows.h>
#include <time.h>
#include <vector>
#include <list>
#include <random>
#include <ctime>
#include <fstream>
#include <stdio.h>
using namespace std;
 
std::random_device rd;
 
char className[] = "WindowClass1";
MSG msg;
HWND hedit, hres_edit;
HINSTANCE hInst;
 
 
double k = 1, k2 = 1000, num2 = 0;
char path[80];
char path2[80];
bool x = true;
 
list <HWND> hndls;
list <HWND>::iterator pos;
 
#define find_id     3000
#define search_id   3001
#define search_id2  3002
#define edit_id     3004
#define edit_id2    3005
#define list_id     3006
#define list_id2    3007
#define back_id     3008
#define back_id2    3009
#define delete_id   3010
#define copy_id     3011
#define move_id     3012
HANDLE bmp;
 
 
LRESULT CALLBACK WndProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam){
    static HWND hstatic;
    static HWND hlistbox, hlistbox2;
    static HWND hbutton, hbutton2, hbutton3;
    static HWND hedit, hedit2;
 
    switch (msg){
 
    case WM_CREATE:
    {
                      //Лист 1
                      hlistbox = CreateWindow("listbox", NULL, WS_CHILD | WS_VISIBLE | LBS_WANTKEYBOARDINPUT | LBS_STANDARD,
                          20, 100, 300, 400, wnd, (HMENU)list_id, hInst, 0);
                      //Лист 2
                      hlistbox2 = CreateWindow("listbox", NULL, WS_CHILD | WS_VISIBLE | LBS_WANTKEYBOARDINPUT | LBS_STANDARD,
                          340, 100, 300, 400, wnd, (HMENU)list_id2, hInst, 0);
 
                      //Окно ввода 1
                      hedit = CreateWindow("edit", "Укажите путь 1", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
                          20, 70, 110, 20, wnd, (HMENU)edit_id, hInst, 0);
                      //Найти 1
                      hbutton = CreateWindow("button", "Найти", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          135, 70, 90, 20, wnd, (HMENU)search_id, hInst, 0);
                      //Назад
                      hbutton = CreateWindow("button", "<--", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          230, 70, 90, 20, wnd, (HMENU)back_id, hInst, 0);
 
                      //Окно воода 2
                      hedit2 = CreateWindow("edit", "Укажите путь 2", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
                          340, 70, 110, 20, wnd, (HMENU)edit_id2, hInst, 0);
                      //Найти 2
                      hbutton2 = CreateWindow("button", "Найти", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          455, 70, 90, 20, wnd, (HMENU)search_id2, hInst, 0);
                      //Назад 2
                      hbutton2 = CreateWindow("button", "<--", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          550, 70, 90, 20, wnd, (HMENU)back_id2, hInst, 0);
 
 
                      hbutton = CreateWindow("button", "Copy", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          20, 500, 95, 20, wnd, (HMENU)copy_id, hInst, 0);
                      hbutton = CreateWindow("button", "Move", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          124, 500, 95, 20, wnd, (HMENU)move_id, hInst, 0);
                      hbutton = CreateWindow("button", "Delete", WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                          230, 500, 90, 20, wnd, (HMENU)delete_id, hInst, 0);
                      return 0;
    }
    case WM_COMMAND:
    {
                       int mes = HIWORD(wParam);
                       int buttonID = LOWORD(wParam);
 
 
                       //LB_RESETCONTENT - очищает поле
                       //LPSTR - char*
                       if ((buttonID == search_id) && (mes == BN_CLICKED)){
                           SendMessage(hlistbox, LB_RESETCONTENT, 0, 0);
                           char path[40];
                           GetWindowText(hedit, path, 40);
                           strcat(path, "*.*");
                           SendMessage(hlistbox, LB_DIR, (WPARAM)(UINT)DDL_DIRECTORY, (LPARAM)(LPSTR)path);
                       }
 
                       if ((buttonID == search_id2) && (mes == BN_CLICKED)){
                           SendMessage(hlistbox2, LB_RESETCONTENT, 0, 0);
                           char path2[40];
                           GetWindowText(hedit2, path2, 40);
                           strcat(path2, "*.*");
                           SendMessage(hlistbox2, LB_DIR, (WPARAM)(UINT)DDL_DIRECTORY, (LPARAM)(LPSTR)path2);
                       }
 
 
                       if ((buttonID == list_id2 && mes == LBN_DBLCLK) || (buttonID == find_id && mes == BN_CLICKED))
                       {
                           // LB_GETCURSEL - возвращает 
                           int n2 = (int)SendMessage(hlistbox2, LB_GETCURSEL, 0, 0), i = 0;
                           char name2[40], txt[] = "txt";
                           SendMessage(hlistbox2, LB_GETTEXT, n2, (LPARAM)name2);
                           GetWindowText(hedit2, path2, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           strcat(path2, name2);
 
                           n2 = 0;
                           SendMessage(hlistbox2, LB_RESETCONTENT, 0, 0);
                           fstream file(path2, ios::in);
                           file.seekg(0, ios::end);
                           long size2 = file.tellg();
                           file.seekg(0, ios::beg);
                           char *str = new char[size2], *str2 = new char[size2];
                           while (!file.eof()){
                               file.getline(str, size2);
                               //LB_INSERTSTRING - указывает на строку куда надо вставлять 
                               SendMessage(hlistbox2, LB_INSERTSTRING, n2++, (LPARAM)str);
                           }
                           file.close();
                       }
 
                       /*if ((buttonID == list_id && mes == LBN_DBLCLK) || (buttonID == find_id && mes == BN_CLICKED))
                       {
                           // LB_GETCURSEL - возвращает 
                           int n = (int)SendMessage(hlistbox, LB_GETCURSEL, 0, 0), i = 0;
                           char name[40], txt[] = "txt";
                           SendMessage(hlistbox, LB_GETTEXT, n, (LPARAM)name);
                           GetWindowText(hedit, path, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           strcat(path, name);
 
                           n = 0;
                           SendMessage(hlistbox, LB_RESETCONTENT, 0, 0);
                           fstream file(path, ios::in);
                           file.seekg(0, ios::end);
                           long size = file.tellg();
                           file.seekg(0, ios::beg);
                           char *str = new char[size], *str2 = new char[size];
                           while (!file.eof()){
                               file.getline(str, size);
                               //LB_INSERTSTRING - указывает на строку куда надо вставлять 
                               SendMessage(hlistbox, LB_INSERTSTRING, n++, (LPARAM)str);
                           }
                           file.close();
                       }*/
                       /////////////////////////////////////////////////////
                       if ((buttonID == delete_id) && (mes == BN_CLICKED))
                       {
                           int n = (int)SendMessage(hlistbox, LB_GETCURSEL, 0, 0);
                           char name[40];
                           SendMessage(hlistbox, LB_GETTEXT, n, (LPARAM)name);
                           GetWindowText(hedit, path, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           strcat(path, name);
 
                           if ((buttonID == delete_id) && (mes == BN_CLICKED))
                           {
                               //if (remove(path) == -1)
                                   //MessageBox(wnd, "Ошибка удаления!", "Ошибка", 0);
                               if (remove(path) != -1){
                                   MessageBox(wnd, "Удаление успешно выполнено!", "Ошибка", 0);
                                   
                                   SendMessage(hlistbox, LB_RESETCONTENT, 0, 0);
                                   for (int i = strlen(path); i >= 0; i--){
                                       path[i] = 0;
                                       if (path[i - 1] == '\\') break;
                                   }
                                   strcat(path, "*.*");
                                   SendMessage(hlistbox, LB_DIR, (WPARAM)(UINT)DDL_DIRECTORY, (LPARAM)(LPSTR)path);
                               }
                           }
                       }
 
                       if ((buttonID == delete_id) && (mes == BN_CLICKED))
                       {
                           int n2 = (int)SendMessage(hlistbox2, LB_GETCURSEL, 0, 0);
                           char name2[40];
                           SendMessage(hlistbox2, LB_GETTEXT, n2, (LPARAM)name2);
                           GetWindowText(hedit2, path2, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           strcat(path2, name2);
 
                           if ((buttonID == delete_id) && (mes == BN_CLICKED))
                           {
                               //if (remove(path2) == -1)
                                   //MessageBox(wnd, "Ошибка удаления!", "Ошибка", 0);
                               if (remove(path2) !=-1){
                                   MessageBox(wnd, "Удаление успешно выполнено!", "Ошибка", 0);
                                   SendMessage(hlistbox2, LB_RESETCONTENT, 0, 0);
                                   
                                   for (int i = strlen(path2); i >= 0; i--){
                                       path2[i] = 0;
                                       if (path2[i - 1] == '\\') break;
                                   }
                                   strcat(path2, "*.*");
                                   SendMessage(hlistbox2, LB_DIR, (WPARAM)(UINT)DDL_DIRECTORY, (LPARAM)(LPSTR)path2);
                               }
                           }
                       }
                       ///////////////////////////////////////////////////////////////////
                       if ((LOWORD(wParam) == copy_id) && (HIWORD(wParam) == BN_CLICKED))
                       {int n2 = (int)SendMessage(hlistbox2, LB_GETCURSEL, 0, 0);
                           char name2[40];
                           SendMessage(hlistbox2, LB_GETTEXT, n2, (LPARAM)name2);
                           GetWindowText(hedit2, path2, 40);
 
                           int n = (int)SendMessage(hlistbox, LB_GETCURSEL, 0, 0);
                           char name[40];
                           SendMessage(hlistbox, LB_GETTEXT, n, (LPARAM)name);
                           GetWindowText(hedit, path, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           strcat(path, name);
 
                           
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           if (strcmp(name, name2) != 0)
                           {
                               strcat(path2, name);
                               char str[900];
 
                               std::fstream f(path, std::ios::in);
                               std::fstream f2(path2, std::ios::out);
                               while (!f.eof())//пока файл не закончен
                               {
                                   f.getline(str, 1999);//читает строку
                                   f2 << str << "\n";//то записываем ее в новый тхт
                               }
                               f.close();
                               f2.close();
                               MessageBox(wnd, "Копирование успешно выполнено!", "", 0);
                           }
                           else{
                               MessageBox(wnd, "Ошибка!Файл с таким именем уже существует.", "", 0);
                               }
                           }
                       
                       
 
                       if ((LOWORD(wParam) == move_id) && (HIWORD(wParam) == BN_CLICKED))
                       {
                           int n = (int)SendMessage(hlistbox, LB_GETCURSEL, 0, 0);
                           char name[40];
                           SendMessage(hlistbox, LB_GETTEXT, n, (LPARAM)name);
                           GetWindowText(hedit, path, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
                           strcat(path, name);
 
                           int n2 = (int)SendMessage(hlistbox2, LB_GETCURSEL, 0, 0), i = 0;
                           char name2[40];
                           SendMessage(hlistbox2, LB_GETTEXT, n2, (LPARAM)name2);
                           GetWindowText(hedit2, path2, 40);
                           //if(path[strlen(path)-1]!='\\') strcat(path, "\\");
 
 
                           if (strcmp(name2, name) != 0)
                           {
                               strcat(path, name2);
                               char str2[900];
 
                               std::fstream f2(path2, std::ios::in);
                               std::fstream f(path, std::ios::out);
                               while (!f2.eof())//пока файл не закончен
                               {
                                   f2.getline(str2, 1999);//читает строку
                                   f << str2 << "\n";//то записываем ее в новый тхт
                               }
                               f.close();
                               f2.close();
                               MessageBox(wnd, "Перемещение успешно выполнено!", "", 0);
                           }
                           if (remove(path2) != -1){
                               //MessageBox(wnd, "Удаление успешно выполнено!", "", 0);
                               //SendMessage(hlistbox2,LB_RESETCONTENT,0,0);
                               SendMessage(hlistbox2, LB_RESETCONTENT, 0, 0);
                               for (int i = strlen(path2); i >= 0; i--){
                                   path2[i] = 0;
                                   if (path2[i - 1] == '\\') break;
                               }
                               strcat(path2, "*.*");
                               SendMessage(hlistbox2, LB_DIR, (WPARAM)(UINT)DDL_DIRECTORY, (LPARAM)(LPSTR)path2);
                           }
                       }
 
                    return 0;
            }
 
    case WM_TIMER:
    {
                     return 0;
    }
 
    case WM_DESTROY: {PostQuitMessage(0); return 0; }
    }
    return DefWindowProc(wnd, msg, wParam, lParam);
}
 
int APIENTRY WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR     lpCmdLine,
    int       nCmdShow)
{
    WNDCLASS wc;
    HWND hwnd;
 
    hInst = hInstance;
 
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(NULL, IDI_QUESTION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.lpfnWndProc = WndProc;
    wc.lpszMenuName = NULL;
    wc.hbrBackground = (HBRUSH)(3);
    wc.lpszClassName = className;
    wc.cbClsExtra = wc.cbWndExtra = wc.style = 0;
 
    int k = RegisterClass(&wc);
 
    hwnd = CreateWindow(className, "Manager", WS_VISIBLE | WS_SYSMENU | WS_MAXIMIZEBOX | WS_THICKFRAME,
        150, 150, 680, 600, NULL, NULL, hInstance, 0);
 
    if (!hwnd) return false;
 
    while (GetMessage(&msg, 0, 0, 0)){
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
 
    return 1;
}
0
 Аватар для Izual
143 / 122 / 21
Регистрация: 13.11.2012
Сообщений: 1,564
24.03.2014, 15:54
Цитата Сообщение от trinkle69 Посмотреть сообщение
только текстовых файлов
Честно сказать с методом через ios не работал и не знаю. Но через fopen (Сишную функцию) достаточно просто поменять ".txt" на любое другое расширение (можете даже сами придумать) - и будет тоже самое. Другое дело работа через бинарный вид...
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
24.03.2014, 15:54
Помогаю со студенческими работами здесь

Необходимо разработать простейший файловый менеджер
Суть задачи в том, что информацию о файлах необходимо получать через таблицу FAT. Возникли трудности с тем, что не могу понять как хранить...

Файловый менеджер. Отображение процесса копирования файла
Мне по курсовой работе нужно сделать файловый менеджер средствами WinApi. Тут мне повезло наткнутся на тему...

Не пересоздается директория QDir, если она открыта через файловый менеджер
Нужно удалить существующую директорию, если она есть и создать новую с тем же именем, т.е. очистить и записать в нее файлы. Все хорошо до...

Файловый менеджер
здравствуйте,возник вопрос как отображать содержимое папки? например есть папка в которой находятся файлы разных типов,пользователь зашел в...

Файловый менеджер
Всем доброго времени суток. в общем нужна помощь, не за даром естественно. необходимо написать файловый менеджер. сама написанная программа...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
Новые блоги и статьи
SDL3 для Web (WebAssembly): Синхронизация спрайтов SDL3 и тел Box2D
8Observer8 04.03.2026
Содержание блога Финальная демка в браузере. Итоговый код: finish-sync-physics-sprites-sdl3-c. zip На первой гифке отладочные линии отключены, а на второй включены:. . .
SDL3 для Web (WebAssembly): Идентификация объектов на Box2D v3 - использование userData и событий коллизий
8Observer8 02.03.2026
Содержание блога Финальная демка в браузере. Итоговый код: finish-collision-events-sdl3-c. zip https:/ / www. cyberforum. ru/ blog_attachment. php?attachmentid=11680&amp;d=1772460536 Одним из. . .
Реалии
Hrethgir 01.03.2026
Нет, я не закончил до сих пор симулятор. Эта задача сложнее. Не получилось уйти в плавсостав, но оно и к лучшему, возможно. Точнее получалось - но сварщиком в палубную команду, а это значит, в моём. . .
Ритм жизни
kumehtar 27.02.2026
Иногда приходится жить в ритме, где дел становится всё больше, а вовлечения в происходящее — всё меньше. Плотный график не даёт вниманию закрепиться ни на одном событии. Утро начинается с быстрых,. . .
SDL3 для Web (WebAssembly): Сборка библиотек: SDL3, Box2D, FreeType, SDL3_ttf, SDL3_mixer и SDL3_image из исходников с помощью CMake и Emscripten
8Observer8 27.02.2026
Недавно вышла версия 3. 4. 2 библиотеки SDL3. На странице официальной релиза доступны исходники, готовые DLL (для x86, x64, arm64), а также библиотеки для разработки под Android, MinGW и Visual Studio. . . .
SDL3 для Web (WebAssembly): Реализация движения на Box2D v3 - трение и коллизии с повёрнутыми стенами
8Observer8 20.02.2026
Содержание блога Box2D позволяет легко создать главного героя, который не проходит сквозь стены и перемещается с заданным трением о препятствия, которые можно располагать под углом, как верхнее. . .
Конвертировать закладки radiotray-ng в m3u-плейлист
damix 19.02.2026
Это можно сделать скриптом для PowerShell. Использование . \СonvertRadiotrayToM3U. ps1 <path_to_bookmarks. json> Рядом с файлом bookmarks. json появится файл bookmarks. m3u с результатом. # Check if. . .
Семь CDC на одном интерфейсе: 5 U[S]ARTов, 1 CAN и 1 SSI
Eddy_Em 18.02.2026
Постепенно допиливаю свою "многоинтерфейсную плату". Выглядит вот так: https:/ / www. cyberforum. ru/ blog_attachment. php?attachmentid=11617&stc=1&d=1771445347 Основана на STM32F303RBT6. На борту пять. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru