Форум программистов, компьютерный форум, киберфорум
C# .NET
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.88/8: Рейтинг темы: голосов - 8, средняя оценка - 4.88
0 / 0 / 0
Регистрация: 30.03.2019
Сообщений: 3
.NET 4.x

Как OpenFileDialog заменить на GetOpenFileName?

30.03.2019, 16:23. Показов 1613. Ответов 1
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
В с# не шарю! Нашел инжектор на c# и хочу переписать так что бы файл не надо было указывать. Строчки которые надо заменить с 325 по конец, в скрипте 340 строк.
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
using InjectionLibrary;
using JLibrary.PortableExecutable;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Management;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace PasteLoader
{
    public struct ColorRGB
    {
        public byte R;
        public byte G;
        public byte B;
 
        public ColorRGB(Color value)
        {
            this.R = value.R;
            this.G = value.G;
            this.B = value.B;
        }
 
        public static implicit operator Color(ColorRGB rgb)
        {
            Color c = Color.FromArgb(rgb.R, rgb.G, rgb.B);
            return c;
        }
 
        public static explicit operator ColorRGB(Color c)
        {
            return new ColorRGB(c);
        }
    }
 
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.CenterToScreen();
            this.ShowInTaskbar = false;
            this.FormBorderStyle = FormBorderStyle.None;
            Task.Factory.StartNew(() => FormChange());
 
            methodType.Items.AddRange(availableMethods);
            methodType.SelectedIndex = 0;
 
            if (!Directory.Exists(@"C:\ProgramData\PasteInjector"))
            {
                Directory.CreateDirectory(@"C:\ProgramData\PasteInjector");
                File.Create(@"C:\ProgramData\PasteInjector\paste.cfg");
            } else
            {
                string[] settings = File.ReadAllText(@"C:\ProgramData\PasteInjector\paste.cfg").Split(';');
                realDLL = settings[0];
                label2.Text = settings[0].Split('\\').Last();
                methodType.SelectedIndex = int.Parse(settings[1]);
            }
        }
 
        bool RGBTitle = false;
        string realDLL = String.Empty;
        string[] availableMethods = { "Standart", "ManualMap" };
 
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int LPAR);
        [DllImport("user32.dll")]
        public static extern bool ReleaseCapture();
 
        private void FormChange()
        {
            if (this.InvokeRequired)
            {
                int value = 0;
                double color = 0;
                while (true)
                {
                    if (value > 58) value = 0;
                    if (color > 1) color = 0;
                    switch (value)
                    {
                        case 0: titleText.Invoke(new Action(() => titleText.Text = " ")); break;
                        case 1: titleText.Invoke(new Action(() => titleText.Text = "/")); break;
                        case 2: titleText.Invoke(new Action(() => titleText.Text = "-")); break;
                        case 3: titleText.Invoke(new Action(() => titleText.Text = "")); break;
                        case 4: titleText.Invoke(new Action(() => titleText.Text = "|")); break;
                        case 5: titleText.Invoke(new Action(() => titleText.Text = "P")); break;
                        case 6: titleText.Invoke(new Action(() => titleText.Text = "P/")); break;
                        case 7: titleText.Invoke(new Action(() => titleText.Text = "P-")); break;
                        case 8: titleText.Invoke(new Action(() => titleText.Text = "P")); break;
                        case 9: titleText.Invoke(new Action(() => titleText.Text = "P|")); break;
                        case 10: titleText.Invoke(new Action(() => titleText.Text = "Pa/")); break;
                        case 11: titleText.Invoke(new Action(() => titleText.Text = "Pa-")); break;
                        case 12: titleText.Invoke(new Action(() => titleText.Text = "Pa")); break;
                        case 13: titleText.Invoke(new Action(() => titleText.Text = "Pa|")); break;
                        case 14: titleText.Invoke(new Action(() => titleText.Text = "Pas/")); break;
                        case 15: titleText.Invoke(new Action(() => titleText.Text = "Pas-")); break;
                        case 16: titleText.Invoke(new Action(() => titleText.Text = "Pas")); break;
                        case 17: titleText.Invoke(new Action(() => titleText.Text = "Pas|")); break;
                        case 18: titleText.Invoke(new Action(() => titleText.Text = "Past/")); break;
                        case 19: titleText.Invoke(new Action(() => titleText.Text = "Past-")); break;
                        case 20: titleText.Invoke(new Action(() => titleText.Text = "Past")); break;
                        case 21: titleText.Invoke(new Action(() => titleText.Text = "Past|")); break;
                        case 22: titleText.Invoke(new Action(() => titleText.Text = "Paste/")); break;
                        case 23: titleText.Invoke(new Action(() => titleText.Text = "Paste-")); break;
                        case 24: titleText.Invoke(new Action(() => titleText.Text = "Paste")); break;
                        case 25: titleText.Invoke(new Action(() => titleText.Text = "Paste|")); break;
                        case 26: titleText.Invoke(new Action(() => titleText.Text = "PasteI/")); break;
                        case 27: titleText.Invoke(new Action(() => titleText.Text = "PasteI-")); break;
                        case 28: titleText.Invoke(new Action(() => titleText.Text = "PasteI")); break;
                        case 29: titleText.Invoke(new Action(() => titleText.Text = "PasteI|")); break;
                        case 30: titleText.Invoke(new Action(() => titleText.Text = "PasteIn/")); break;
                        case 31: titleText.Invoke(new Action(() => titleText.Text = "PasteIn-")); break;
                        case 32: titleText.Invoke(new Action(() => titleText.Text = "PasteIn")); break;
                        case 33: titleText.Invoke(new Action(() => titleText.Text = "PasteIn|")); break;
                        case 34: titleText.Invoke(new Action(() => titleText.Text = "PasteInj/")); break;
                        case 35: titleText.Invoke(new Action(() => titleText.Text = "PasteInj-")); break;
                        case 36: titleText.Invoke(new Action(() => titleText.Text = "PasteInj")); break;
                        case 37: titleText.Invoke(new Action(() => titleText.Text = "PasteInj|")); break;
                        case 38: titleText.Invoke(new Action(() => titleText.Text = "PasteInje/")); break;
                        case 39: titleText.Invoke(new Action(() => titleText.Text = "PasteInje-")); break;
                        case 40: titleText.Invoke(new Action(() => titleText.Text = "PasteInje")); break;
                        case 41: titleText.Invoke(new Action(() => titleText.Text = "PasteInje|")); break;
                        case 42: titleText.Invoke(new Action(() => titleText.Text = "PasteInjec/")); break;
                        case 43: titleText.Invoke(new Action(() => titleText.Text = "PasteInjec-")); break;
                        case 44: titleText.Invoke(new Action(() => titleText.Text = "PasteInjec")); break;
                        case 45: titleText.Invoke(new Action(() => titleText.Text = "PasteInjec|")); break;
                        case 46: titleText.Invoke(new Action(() => titleText.Text = "PasteInject/")); break;
                        case 47: titleText.Invoke(new Action(() => titleText.Text = "PasteInject-")); break;
                        case 48: titleText.Invoke(new Action(() => titleText.Text = "PasteInject")); break;
                        case 49: titleText.Invoke(new Action(() => titleText.Text = "PasteInject|")); break;
                        case 50: titleText.Invoke(new Action(() => titleText.Text = "PasteInjecto/")); break;
                        case 51: titleText.Invoke(new Action(() => titleText.Text = "PasteInjecto-")); break;
                        case 52: titleText.Invoke(new Action(() => titleText.Text = "PasteInjecto")); break;
                        case 53: titleText.Invoke(new Action(() => titleText.Text = "PasteInjecto|")); break;
                        case 54: titleText.Invoke(new Action(() => titleText.Text = "PasteInjector")); break;
                        case 55: titleText.Invoke(new Action(() => titleText.Text = " ")); break;
                        case 56: titleText.Invoke(new Action(() => titleText.Text = "PasteInjector")); break;
                        case 57: titleText.Invoke(new Action(() => titleText.Text = " ")); break;
                        case 58: titleText.Invoke(new Action(() => titleText.Text = "PasteInjector")); break;
                    }
                    value++;
                    if(RGBTitle)
                        titleText.Invoke(new Action(() => titleText.ForeColor = HSL2RGB(color, 0.5, 0.5)));
                        color+=0.01;
                    Thread.Sleep(70);
                }
            }
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            if (label2.Text == "Выбрать файл" || !File.Exists(realDLL))
            {
                MessageBox.Show("Сначала выберите файл", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            InjectionMethod injector = null;
 
            if (methodType.SelectedIndex == 0)
            {
                injector = InjectionMethod.Create(InjectionMethodType.Standard);
            } else
            {
                injector = InjectionMethod.Create(InjectionMethodType.ManualMap);
            }
 
            Process[] processes = Process.GetProcessesByName("csgo");
            if (processes.Length <= 0)
            {
                MessageBox.Show("Сначала запустите CS:GO", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                int processId = processes[0].Id;
                IntPtr result = IntPtr.Zero;
                using (PortableExecutable pe = new PortableExecutable(realDLL))
                {
                    result = injector.Inject(pe, processId);
                }
                if (result != IntPtr.Zero)
                {
                    File.WriteAllText(@"C:\ProgramData\PasteInjector\paste.cfg", realDLL + ";" + methodType.SelectedIndex.ToString());
                    MessageBox.Show("Успешный инжект!");
                    Application.Exit();
                }
                else
                {
                    if (injector.GetLastError() != null)
                    {
                        MessageBox.Show(injector.GetLastError().Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Environment.Exit(0);
                    }
                }
            }
        }
 
        const int WM_NCLBUTTONDOWN = 0xA1;
        const int HT_CAPTION = 0x2; 
 
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
 
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
 
        private void closeButton_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }
 
        private void titleText_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
 
        private void label1_Click(object sender, EventArgs e)
        {
            Process.Start("https://yougame.biz/");
        }
 
        
        public static ColorRGB HSL2RGB(double h, double sl, double l)
        {
            double v;
            double r, g, b;
 
            r = l;   // default to gray
            g = l;
            b = l;
            v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl);
 
            if (v > 0)
            {
                double m;
                double sv;
                int sextant;
                double fract, vsf, mid1, mid2;
 
                m = l + l - v;
                sv = (v - m) / v;
                h *= 6.0;
 
                sextant = (int)h;
                fract = h - sextant;
                vsf = v * sv * fract;
                mid1 = m + vsf;
                mid2 = v - vsf;
                switch (sextant)
                {
                    case 0:
                        r = v;
                        g = mid1;
                        b = m;
                        break;
                    case 1:
                        r = mid2;
                        g = v;
                        b = m;
                        break;
                    case 2:
                        r = m;
                        g = v;
                        b = mid1;
                        break;
                    case 3:
                        r = m;
                        g = mid2;
                        b = v;
                        break;
                    case 4:
                        r = mid1;
                        g = m;
                        b = v;
                        break;
                    case 5:
                        r = v;
                        g = m;
                        b = mid2;
                        break;
                }
            }
 
            ColorRGB rgb;
            rgb.R = Convert.ToByte(r * 255.0f);
            rgb.G = Convert.ToByte(g * 255.0f);
            rgb.B = Convert.ToByte(b * 255.0f);
            return rgb;
        }
 
        private void selectDLL_Click(object sender, EventArgs e)
        {
            OpenFileDialog OFD = new OpenFileDialog() { Filter = "DLL-файлы|*.dll" };
            if (OFD.ShowDialog() == DialogResult.OK)
            {
                realDLL = OFD.FileName;
                label2.Text = OFD.FileName.Split('\\').Last();
            } else {
                return;
            }
        }
    }
}
0
Лучшие ответы (1)
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
30.03.2019, 16:23
Ответы с готовыми решениями:

Чем заменить OpenFileDialog в MVVM?
В WPF как оказывается такой функции нет. Подскажите пожалуйста каким образом сделать аналог? Может быть есть какие нибудь готовые аналоги?...

Как в VB работает GetOpenFileName?
Нужен фрагмент кода, чтобы в переменной сохранить имя файла, выбранного пользователем в стандартном диалоге 'Открыть'. Так, как делал...

Как GetOpenFileName без CDERR_INITIALIZATION
Кому-нибудь удалось в Lua 5.1 применить GetOpenFileName() из Win32 API? В &quot;C&quot; аналогичный код выполняется успешно, в Lua возвращает 0, а...

1
296 / 120 / 33
Регистрация: 06.03.2016
Сообщений: 453
04.04.2019, 12:07
Лучший ответ Сообщение было отмечено IlyaBidloProger как решение

Решение

не хочешь выбирать в окне - пропиши в 75 строке полный путь к файлу с расширением
C#
1
string realDLL = String.Empty; // вместо string.empty путь к файлу "C:\\Games\\...\\file.dll"
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
04.04.2019, 12:07
Помогаю со студенческими работами здесь

Как работать с методом GetOpenFileName?
Ребят, помогите написать блок. Например, надо открыть несколько файлов из &quot;d:\ТЕМП\фото&quot; формата jpg как быть? с чего начать? ...

Как в GetOpenFileName выбрать сразу несколько файлов?
Подскажите, пожалуйста! Что отвечает за выбор сразу нескольких файлов?:( Public Declare Function GetOpenFileName Lib _ ...

OpenFileDialog как им пользоваться?
Нужно по нажатию кнопки открыть диалог, выбрать фаил, после нажатия кнопки открыть скопировать адрес фаила в переменную.

Как работать с OpenFileDialog?
выбрал фаил при помощи данного контрола! и где этот фаил оказывается после закрытия окна отображения!? как получить к нему доступ?

Как вызвать OpenFileDialog
using Microsoft.Win32; ... private void button2_Click(object sender, EventArgs e) { ...


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

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
Новые блоги и статьи
Инструменты COM: Сохранение данный из VARIANT в файл и загрузка из файла в VARIANT
bedvit 28.01.2026
Сохранение базовых типов COM и массивов (одномерных или двухмерных) любой вложенности (деревья) в файл, с возможностью выбора алгоритмов сжатия и шифрования. Часть библиотеки BedvitCOM Использованы. . .
Загрузка PNG с альфа-каналом на SDL3 для Android: с помощью SDL_LoadPNG (без SDL3_image)
8Observer8 28.01.2026
Содержание блога SDL3 имеет собственные средства для загрузки и отображения PNG-файлов с альфа-каналом и базовой работы с ними. В этой инструкции используется функция SDL_LoadPNG(), которая. . .
Загрузка PNG с альфа-каналом на SDL3 для Android: с помощью SDL3_image
8Observer8 27.01.2026
Содержание блога SDL3_image - это библиотека для загрузки и работы с изображениями. Эта пошаговая инструкция покажет, как загрузить и вывести на экран смартфона картинку с альфа-каналом, то есть с. . .
Влияние грибов на сукцессию
anaschu 26.01.2026
Бифуркационные изменения массы гриба происходят тогда, когда мы уменьшаем массу компоста в 10 раз, а скорость прироста биомассы уменьшаем в три раза. Скорость прироста биомассы может уменьшаться за. . .
Воспроизведение звукового файла с помощью SDL3_mixer при касании экрана Android
8Observer8 26.01.2026
Содержание блога SDL3_mixer - это библиотека я для воспроизведения аудио. В отличие от инструкции по добавлению текста код по проигрыванию звука уже содержится в шаблоне примера. Нужно только. . .
Установка Android SDK, NDK, JDK, CMake и т.д.
8Observer8 25.01.2026
Содержание блога Перейдите по ссылке: https:/ / developer. android. com/ studio и в самом низу страницы кликните по архиву "commandlinetools-win-xxxxxx_latest. zip" Извлеките архив и вы увидите. . .
Вывод текста со шрифтом TTF на Android с помощью библиотеки SDL3_ttf
8Observer8 25.01.2026
Содержание блога Если у вас не установлены Android SDK, NDK, JDK, и т. д. то сделайте это по следующей инструкции: Установка Android SDK, NDK, JDK, CMake и т. д. Сборка примера Скачайте. . .
Использование SDL3-callbacks вместо функции main() на Android, Desktop и WebAssembly
8Observer8 24.01.2026
Содержание блога Если вы откроете примеры для начинающих на официальном репозитории SDL3 в папке: examples, то вы увидите, что все примеры используют следующие четыре обязательные функции, а. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru