0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

これ、収録してる?

Posted at

 とあるゲームで、ゲームを収録している人には特殊演出が入る仕様があると聞きました。

 面白そうと思ったので、これの実装方法を考えてみました。メタ要素のあるゲームを作りたい方は参考にしてみて下さい。
 ……あ、言い忘れていましたがC言語です。C++でももちろん動きます。あと、Windowsでしか動きません。

#include <Windows.h>
#include <stdio.h>

BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lp) {
	TCHAR window_text[1024];
	GetWindowText(hWnd, window_text, 1024);
	if (window_text[0] == L'O' && window_text[1] == L'B' && window_text[2] == L'S') {
		*(bool*)lp = true;
	}
	return TRUE;
}

int main(void) {
	bool is_obs = false;
	EnumWindows(EnumWindowsProc, (LPARAM)(&is_obs));
	if (is_obs) {
		printf("収録してる\n");
	}
}

 Windows APIのEnumWindowsという関数を使っています。ウィンドウ名がOBSの三文字で始まる時、「収録してる」と表示されるプログラムです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?