In win7, a simple atl com was created with vc2010, but the compilation was successful, but the registration failed. The prompt is:
"Warning msb3075: Command" regsvr32/s "E: \ Program \ vc2010 \ testcom3 \ debug \ testcom3.dll" "has exited,CodeIs 5. Verify that you have sufficient permissions to run this command. "
Obviously: This is a problem with insufficient permissions. If the same code is stored in Win XP, there may be no problems, but this problem occurs in win7. This is because Windows 7 has strict permission management.
Analyze code,Register DLLThe code is: _ Atlmodule. dllregisterserver ();The task of this function is to write information to the registry, but it cannot be written due to permission issues.
Solution:
RunATL: atlsetperuserregistration (true );// ApplyProgramTo HKEY_CURRENT_USER.
Recompile and check that the registration is successful!
Similarly, in order to implement the successful execution of dllunregisterserver, You need to execute _ atlmodule. dllunregisterserver ();ATL: atlsetperuserregistration (true );That is
Stdapi dllunregisterserver (void) {ATL: atlsetperuserregistration (true); hresult hR = _ atlmodule. dllunregisterserver (); Return hr ;}