Windows手动加载MSVCRT.DLL库

xingyun86 2018-8-10 2207

void LoadMSVCRT90()
{
	_TCHAR sDllName[] = _T("MSVCR90.DLL");
	HMODULE hLib = NULL;
	ACTCTX aActCtx = { 0 };
	HANDLE hCtx = NULL;
	ULONG_PTR lpCookie = 0L;
	memset(&aActCtx, 0, sizeof(aActCtx));
	aActCtx.cbSize = sizeof(aActCtx);
	aActCtx.lpSource = _T("MSVCRT.manifest");
	hCtx = ::CreateActCtx(&aActCtx);
	if (hCtx == INVALID_HANDLE_VALUE)
	{
		return;
	}
	::ActivateActCtx(hCtx, &lpCookie);
	hLib = ::LoadLibrary(sDllName);
	if (!hLib || hLib == INVALID_HANDLE_VALUE)
	{
		return;
	}
	::DeactivateActCtx(0, lpCookie);
	::ReleaseActCtx(hCtx);
}
/*************************************************************************************************
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>
*************************************************************************************************/


×
打赏作者
最新回复 (0)
查看全部
全部楼主
返回