Через командную строку можно:
CODE:
#define TH32CS_SNAPPROCESS 2
#define PROCESS_ALL_ACCESS 2097151
#define STARTF_USESHOWWINDOW 1
external(INT, "CreateProcess", "CreateProcessA", "Kernel32.dll");
external(INT, "CreateToolhelp32Snapshot", "CreateToolhelp32Snapshot", "Kernel32.dll");
external(INT, "Process32First", "Process32First", "Kernel32.dll");
external(INT, "Process32Next", "Process32Next", "Kernel32.dll");
external(INT, "CloseHandle", "CloseHandle", "Kernel32.dll");
system_("/c "+"netsh interface set interface name=^"Ethernet^" admin=DISABLED"); // ENABLED
function system_(string CommandLine){
int STARTUPINFOA[17], PROCESS_INFORMATION[4];
initialarray(#STARTUPINFOA[0], 0);
STARTUPINFOA[0]=68;
STARTUPINFOA[11]=STARTF_USESHOWWINDOW; // не показывать окно
if(CreateProcess(0, "cmd.exe "+CommandLine, 0, 0, 0, 0, 0, 0, address(#STARTUPINFOA[0]), address(#PROCESS_INFORMATION[0])))
{
while(findprocess(PROCESS_INFORMATION[2]))sleep(10); // ждать пока процесс существует
CloseHandle(PROCESS_INFORMATION[0]);
}
}
function findprocess(int PID)
{
char PROCESSENTRY32[296];
int exists=0, hSnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hSnapshot)
{
writeaddress(sizearray(PROCESSENTRY32), address(#PROCESSENTRY32[0]));
Process32First(hSnapshot, address(#PROCESSENTRY32[0]));
while(Process32Next(hSnapshot, address(#PROCESSENTRY32[0])))
{
if(codhexi(#PROCESSENTRY32[8], 4) == PID){exists++; break;}
}
CloseHandle(hSnapshot);
if(exists)return 1;
}
return 0;
}
name=^"Ethernet^" - указать имя своего подключения
(Отредактировано автором: 26 Ноября, 2020 - 15:14:24) |