Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
Final commit
  • Loading branch information
TsSaltan committed Jan 27, 2017
1 parent fb71047 commit 41d89eb
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

build/*/
build/*
.idea
.gradle/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
65 changes: 65 additions & 0 deletions test/test-drives.php.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?// :2>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
}
}
...
*/
41 changes: 41 additions & 0 deletions test/test-registry.php.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?// :2>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";
}
}
24 changes: 24 additions & 0 deletions test/test-tasks.php.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?// :2>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();
41 changes: 2 additions & 39 deletions test/test.php.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}//*/
var_dump(['uuid' => Windows::getUUID()]);

0 comments on commit 41d89eb

Please sign in to comment.