Windows编程 - 遍历程序当前进程中加载的动态链接库(dll) C++

WCHAR szModule[128] = L"caldav.dll";
	HANDLE hShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
	int err = GetLastError();
	if (hShot == INVALID_HANDLE_VALUE)
	{
		printf("创建进程快照失败");
		return 0;
	}

	bool retFind = false;
	MODULEENTRY32 te = { sizeof(te) };
	BOOL bRet = Module32First(hShot, &te);
	while (bRet) { //temp.Format("%d",te.th32HeapID);
				   //m_threadid.AddString(te.szModule);
		wprintf(te.szModule);
		printf("\n");
		if (0 == memcmp(szModule, te.szModule, wcslen(szModule)))
		{
			retFind = true;
			break;
		}
		bRet = Module32Next(hShot, &te);
	}
	CloseHandle(hShot);

	if (retFind)
	{
		printf("11111111111\n");
	}
	else
	{
		printf("000000000000\n");
	}
    return 0;

 

你可能感兴趣的:(C/C++)