Skip to content

Instantly share code, notes, and snippets.

@uemuraj
uemuraj / FolderIcons.ps1
Last active January 11, 2023 02:46
エクスプローラーの「PC」に表示されるアイコンを選択します
<#
.SYNOPSIS
エクスプローラーの「PC」に表示されるアイコンを選択します
.DESCRIPTION
以下のキーを使って操作します。
[ENTER] ... 選択結果をレジストリへ書き込んで終了します。選択は、サインアウト後に有効になります。
[SPACE] ... 各項目を On/Off できます。
[UP][DOWN] ... 項目間を移動できます。
[ESC] ... 何もせず終了します。
@uemuraj
uemuraj / VMList.ps1
Created November 5, 2022 04:30
動作中の仮想マシンを適当に確認したい時に
function Get-VMList {
$credential = Import-CliXml -Path .\ServerCred.xml
$informations = @()
foreach ($vm in (Get-VM | Where-Object State -eq Running)) {
$informations += Invoke-Command -VMName $vm.Name -Credential $credential -ScriptBlock {
$info = Get-ComputerInfo | Select-Object -Property @{Name = "OS"; Expression = { $_.WindowsProductName + ' ' + $_.OSDisplayVersion } }, @{Name = "Name"; Expression = { $_.CsName } }
$info | Add-Member -MemberType NoteProperty -Name IP -Value (Get-NetIPAddress -AddressFamily IPv4 | Where-Object InterfaceAlias -notlike 'Loopback*' | ForEach-Object { $_.IPAddress })
Write-Output $info
}
@uemuraj
uemuraj / VirtualDisk.cpp
Last active October 11, 2022 04:19
ISO ファイルをマウントしてプログラムから使用する。
#define INITGUID
#include <Windows.h>
#include <virtdisk.h>
#include <locale>
#include <iostream>
#include <filesystem>
#include <system_error>
@uemuraj
uemuraj / trace.cpp
Last active October 1, 2022 08:01
畳み込みを使った何か。
#include "trace.h"
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#include <streambuf>
#include <system_error>
namespace trace
{
@uemuraj
uemuraj / cleanup_resource.cpp
Created September 30, 2022 07:32
スコープを抜ける前に後始末をするマクロ
// スコープを抜ける前に後始末をするマクロ
#define MACRO_CLEANUP_RESOURCE(P, D) std::unique_ptr<std::remove_pointer<decltype(P)>::type, decltype(&D)> cleanup_##P(P, D)
@uemuraj
uemuraj / test.cpp
Created June 4, 2022 01:12
複数の値を返す何か。
#include "pch.h"
#include <algorithm>
#include <initializer_list>
struct
{
long min;
long max;
}
@uemuraj
uemuraj / source_location.cpp
Created December 31, 2021 03:05
いつからか分かりませんが __builtin_FILE(), __builtin_LINE(), ... は VC++ でも使えるようです
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#pragma message("__cplusplus=" _CRT_STRINGIZE(__cplusplus)) // 「追加のオプション」で /Zc:__cplusplus を足すのを忘れない
#include <locale>
#include <string>
#include <iostream>
#if __cplusplus >= 202002L

_countof() が使えるのは...

#include <stdlib.h>

stdlib.h をインクルードした時なのだけれど、この定義は、

#ifndef _countof
    #define _countof __crt_countof
#endif
@uemuraj
uemuraj / timestamp.md
Last active September 16, 2021 00:24
Powershell でファイルのタイムスタンプをあれこれする

Powershell でファイルのタイムスタンプをあれこれする

> Get-ChildItem '.\新規 Text Document.txt' | Select-Object -Property CreationTime

CreationTime
------------
2021/06/30 11:31:54
@uemuraj
uemuraj / dumplnk.bat
Created June 3, 2021 07:18
Windows のショートカット( *.lnk ファイル)の設定内容を確認する
@powershell -Command "(New-Object -ComObject WScript.Shell).CreateShortcut("""%~dpf1""")"