因为本人不懂c艹,所以难免会写出一些匪夷所思的代码,欢迎大佬们指正.

// abc.cpp : Defines the entry point for the application.
//
#include <stdio.h>
#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	HKEY hKey;
	HKEY hKey2;
	//麦克风的话改成{33D9A762-90C8-11D0-BD43-00A0C911CE86}
	char path[MAX_PATH] ={"Software\\Microsoft\\ActiveMovie\\devenum\\{E0F158E1-CB04-11D0-BD4E-00A0C911CE86}\\"};
	RegOpenKeyEx(HKEY_CURRENT_USER, path, 0L, KEY_READ, &hKey);
	DWORD KeyCnt;
	RegQueryInfoKey(hKey,NULL,NULL,NULL,&KeyCnt,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
	TCHAR keyName[MAX_PATH];
	DWORD charLength = 260;  
	char dwValue[MAX_PATH];
	DWORD dwSize = 260;
	DWORD id;
	DWORD idSize = 20;
	for (int i=0;i<KeyCnt;i++)
	{
		RegEnumKey(hKey,i,keyName,charLength);
		if (strstr(keyName,"wave")){
			char tmp[MAX_PATH];
			sprintf(tmp, "%s%s", path, keyName);
			RegOpenKeyEx(HKEY_CURRENT_USER, tmp, 0L, KEY_READ, &hKey2);
			RegQueryValueExA(hKey2,"FriendlyName", NULL,NULL, (LPBYTE)dwValue, &dwSize);
			RegQueryValueExA(hKey2,"WaveOutId", NULL,NULL, (LPBYTE)&id, &idSize);
			RegCloseKey(hKey2);
			char tmp2[20]; //
			ltoa(id,tmp2,10);
			MessageBox(NULL,dwValue,tmp2, NULL);
			dwSize = 260;
			idSize = 20;
		}
	}
	return 0;
}
说点什么
支持Markdown语法
好耶,沙发还空着ヾ(≧▽≦*)o
Loading...