diff --git a/.gitignore b/.gitignore index 0f86dd3..156c3f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build/*/ +build/* .idea .gradle/ diff --git a/src/vendor/develnext.bundle.windows.WindowsBundle/bundle/windows/Startup.php b/src/vendor/develnext.bundle.windows.WindowsBundle/bundle/windows/Startup.php index 82be048..a1c6712 100644 --- a/src/vendor/develnext.bundle.windows.WindowsBundle/bundle/windows/Startup.php +++ b/src/vendor/develnext.bundle.windows.WindowsBundle/bundle/windows/Startup.php @@ -50,7 +50,7 @@ public static function add($file, $description = null){ public static function find($file){ $list = self::getList(); foreach($list as $item){ - if($item->file() == $file){ + if($item->file == $file){ return $item; } } diff --git a/test/test-drives.php.bat b/test/test-drives.php.bat new file mode 100644 index 0000000..0c42acb --- /dev/null +++ b/test/test-drives.php.bat @@ -0,0 +1,65 @@ +nul&chcp 65001&cls&java -jar "%~dp0jphp-exec.jar" "%~0"&pause&exit /b +define('DS', '\\'); +define('DIR', __DIR__ . DS); +include DIR . "autoloader.inc.php"; + +### + +use bundle\windows\Windows; + + +$drives = Windows::getDrives(); +foreach($drives as $drive){ + var_dump([$drive['Name'] => [ + 'title' => $drive['VolumeName'], + 'description' => $drive['Description'], + 'serial' => Windows::getDriveSerial($drive['Name']) + ]]); +} + +/* output: +... +array(1) { + ["E:"]=> + array(3) { + ["title"]=> + string(9) "HDD/Media" + ["description"]=> + string(24) "Локальный несъемный диск" + ["serial"]=> + string(8) "3ND1XKS8" + } +} +array(1) { + ["F:"]=> + array(3) { + ["title"]=> + string(7) "HDD/Dev" + ["description"]=> + string(24) "Локальный несъемный диск" + ["serial"]=> + string(8) "3ND1XKS8" + } +} +array(1) { + ["G:"]=> + array(3) { + ["title"]=> + string(4) "E200" + ["description"]=> + string(12) "Съемный диск" + ["serial"]=> + string(4) "UBI0" + } +} +array(1) { + ["H:"]=> + array(3) { + ["description"]=> + string(12) "Компакт-диск" + ["serial"]=> + NULL + } +} +... +*/ \ No newline at end of file diff --git a/test/test-registry.php.bat b/test/test-registry.php.bat new file mode 100644 index 0000000..3ba6b3c --- /dev/null +++ b/test/test-registry.php.bat @@ -0,0 +1,41 @@ +nul&chcp 65001&cls&java -jar "%~dp0jphp-exec.jar" "%~0"&pause&exit /b +define('DS', '\\'); +define('DIR', __DIR__ . DS); +include DIR . "autoloader.inc.php"; + +### + +use bundle\windows\Windows; +use bundle\windows\Registry; +use bundle\windows\Task; + +echo "\n### test 1 ###\n"; +foreach(Registry::of('HKEY_USERS')->search('S-1-5-21-*') as $item){ + var_dump($item->path); +} + +echo "\n### test 2 ###\n"; +$reg = Registry::of('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer')->readFully(); +foreach($reg as $r){ + echo "[" . $r->path . "]\n"; + foreach($r as $v){ + echo $v->key .' = '. $v->value . "\n"; + } +} + +echo "\n### test 3 ###\n"; + +$reg = new Registry('HKEY_CURRENT_USER\SOFTWARE\test_from_dn'); +$reg->create(); // создание ветви +$reg->add('my_key', 'my_value'); // добавление записей +$reg->add('my_key_2', 'my_value'); +$reg->add('my_new_key', 'my_new_value'); + +// Поиск по значениям +$search = $reg->searchValue('my_val*'); +foreach($search as $items){ + echo '[' . $items->path . "]\n"; + foreach ($items as $item){ + echo $item->key . ' = ' . $item->value . "\n"; + } +} \ No newline at end of file diff --git a/test/test-tasks.php.bat b/test/test-tasks.php.bat new file mode 100644 index 0000000..b2226c9 --- /dev/null +++ b/test/test-tasks.php.bat @@ -0,0 +1,24 @@ +nul&chcp 65001&cls&java -jar "%~dp0jphp-exec.jar" "%~0"&pause&exit /b +define('DS', '\\'); +define('DIR', __DIR__ . DS); +include DIR . "autoloader.inc.php"; + +### + +use bundle\windows\Task; + + +$tasks = Task::find('opera.exe'); + +$tab = null; +$memory = 0; + +foreach($tasks as $task){ + if(!is_null($task->title))$tab = $task->title; + $memory += $task->memory; +} + +echo "Task opera.exe used " . $tasks->length() . " processes \n"; +echo "Memory used " . round($memory / 1024 / 1024, 3) . " MiB \n"; +echo "Opened tab: " . $tab; +//$tasks->kill(); \ No newline at end of file diff --git a/test/test.php.bat b/test/test.php.bat index d08bb39..500b1dd 100644 --- a/test/test.php.bat +++ b/test/test.php.bat @@ -6,46 +6,9 @@ include DIR . "autoloader.inc.php"; ### use bundle\windows\Windows; -use bundle\windows\Registry; -use bundle\windows\Task; -foreach(Registry::of('HKEY_USERS')->search('S-1-5-21-*') as $item){ - var_dump($item->path); -} - -/* var_dump(['is_admin' => Windows::isAdmin()]); var_dump(['temp' => Windows::expandEnv('%TEMP%')]); +var_dump(['appData' => Windows::expandEnv('%appdata%')]); var_dump(['arch' => Windows::getArch()]); -var_dump(['uuid' => Windows::getUUID()]); - -$drives = Windows::getDrives(); -foreach($drives as $drive){ - var_dump([$drive['Name'] => [ - 'title' => $drive['VolumeName'], - 'description' => $drive['Description'], - 'serial' => Windows::getDriveSerial($drive['Name']) - ]]); -} -//*/ -/* -$reg = Registry::of('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer')->readFully(); -foreach($reg as $r){ - $r->path = 'хуй'; - echo "\n\n[path] " . $r->path . " ################################\n"; - foreach($r as $v){ - $k = $v->value; - $v->value = $v->key; - $v->key = $k; - var_dump([$v->key => $v->value]); - } -}//*/ - -/* -$tasks = Task::exists('opera.exe'); -var_dump($tasks); -//$tasks->kill(); -/* -foreach($tasks as $task){ - var_dump($task->toArray()); -}//*/ \ No newline at end of file +var_dump(['uuid' => Windows::getUUID()]); \ No newline at end of file