DLL self-registration: how to register just for the current user? - visual-c++

I'm using Visual C++. I'd like to really only have the DLL registered for the current user, even if the users is an administrator.
For that reason, I changed all of the project.rgs references to HKCR.
But, using Process Monitor while using regsvr32 to register the DLL, I notice that it still tries to create HKCR\TypeLib\{ ... }.
This happens on the call to CComModule::RegisterServer().
Is this inherent of CComModule? Is there anything I'm missing, in terms of configuration of Visual C++? I know that I can use RegOverridePredefKey, but I don't want to load more DLLs, and it's not a very elegant solution.

CComModule::RegisterServer() has a BOOL first parameter that indicates whether it should register the type library. Set it to FALSE and it will not try to.

HKCR is not mapped to the current user registry hive, if you really want to register the server for the local user use HKEY_CURRENT_USER\Software\Classes instead of HKCR.

Related

Can't seem to load a managed dll from Installer during setup?

I'm developing an installer for an application which includes a Windows Service. The service will need a username/password from the user in order to get information from our server, so I'd like to set that during install. We also need to store that info in the Services config file so it has to be encrypted.
So I'd like the installer to call the same .dll the service uses when it encrypts the credentials. I set up custom actions created through the custom action wizard. I set it to "Call a public method in a managed assembly" and picked "Installed with the product" as the Location. I'm able to pick the dll and the target function and set everything up through the wizard. The path it resolves to in the installer log looks correct...
But I'm getting the error:
Unable to load managed custom action assembly
So not sure what to do in order to get this working?
The second part of the question is, what happens if the end user doesn't have .NET 4 installed? I'm going to set the installer to install it... but will there be problems or will we need to force a reboot partway through the install process? If so I might just temporarily store things unencrypted and have the service encrypt them when it first runs... which at this point is probably the easy way, but it doesn't feel like the "correct" way. ;)

Are there recent Microsoft changes affecting the behavior of AppInitDLLs registry entry?

I support a product that detects unique key combinations when pressed to launch a notification alert.
This monitoring is done by a dll that is injected. Originally this was done specifically to winlogon.exe, but due to some changes in Vista we added the reference to our dll in AppInitDLLs to have it injected into every running process.
This is not working on my newest development machine, and some behavior on client machines mimicks the behavior. Another dll listed, C:\Windows\system32\nvinitx.dll, is still correctly being loaded, but mine is not.
Are there any known recent security patches that may affect this?
there are no new security changes as far as I know, you can inject any dll (but it must be compatible with the process you are injecting into) like if the process is 32bit your dll must be 32 and if the process is 64bit u need to inject 64bit or odd behavior will appear. another things that there is a new bool value must be set in windows 7 (not sure in vista) that is
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\LoadAppInit_DLLs" must be set to one

How to have just ONE instance running of an exe with 3.5 .NET framework and CE windows 5.0

I've searched long and hard for an answer to my question and have found answers only to a class that does not exist in the 3.5 .NET frameworks version (and with CE Windows 5.0.) Also, it's Visual C# with Visual Studio 2008.
When I try the following (using System.Threading)
bool ok;
Mutex myMutex = new Mutex();
ok = Mutex(true,"scanner", out ok);
The compiler complains that the Mutex is a type, but used as a variable. If I use a [STAThread], it also complains that it can't find it and I"m forced to use [MTAThread].
Are the classes for the mobile device type of c# programs the same for console based ones? I'm somewhat new to this and the idea of how to declare, use, lock and everything you wanted to know about a mutex is making my head sore. O.o I suspect it's because the classes are different from the console verseions and the mobile versions.
It seems so simple, create a mutex, check for it's existance, if so then don't start a new exe instance. That is all I want...just run one instance of any exe. This is a mobile device thus it's a standalone and I never have to worry about anyone else using the .exe. Just need to stop the user from tapping the start button 15 times and having 15 instances of the application running (then complain about low memory usage!)
I've read that a good way is to create a thread, lock it then check if the lock was successful to test if an instance of an exe is already running, close it if so else run the exe. Is there an easier way to do this?
One way to approach this would be to open a file for writing. Only one instance of the application could obtain this lock at a time. On startup, try and obtain a file handle for writing, if it fails, there must be another instance already running: exit immediately.
I think you can forget mutexes since we are talking about separate proceses here.

Hklm/Init on Windows CE 6.0

I've been trying to make my application run at startup on windows CE 6.0, unfortunately since the device (YFAtlas4) is customized by manufacturer I'm unable to place shortcut in \Windows\Startup. (for some misterious reasons)
So now I'm trying to place path to my application in Hklm\Init registry key, and here's my problem: I's there a way to place absolute path there ? In every example that I've seen there's only application name, and my application has to be instaled in \ResidentFlash\ folder.
Did you try to put the full path there?
There should not be any problem doing so.
If you edit your registry using code, then the string you want to store is L"\\ResidentFlash\\AppName.exe". Alternatively, in case you have an ActiveSync connection with the device you can use a remote registry editor and not mess with the double backslashes.
Also, since you are using the HKLM\Init functionality - make sure your application calls SignalStarted so other programs that are dependent on it can start as well.
A fully qualified path should be supported jusy fine. Be aware that if the path has a space in it, you'll need to quote delimit it. Also, if it's a Compact Framework app, it's not as simple as just adding your app to the Init key - often that will fail. See this blog entry on getting CF apps working with the Init key.

Windows XP: RegSvr32 /i:[cmdline]: What exactly is "Command line" in this case?

I am trying to register a dll using regsvr32 in a cmd window. I do this on an administrator account, but I need this dll to be registered for all the users. Turns out regsvr32 does not do that, it only registers for your current user. Well, when you use it this way anyways: "regsvr32 /i "C:\MyDll.dll"" What happens; The entry is added to Local_User, and Classes in the registry, but not Local_Machine.
The msdn article on regsvr32 says it also takes a [cmdline] when using the /i option. But the article fails to specify what I can put in place of [cmdline]. Google is refusing to help me as well, so I'm a bit stuck on this.
I realize this is not exactly on the topic of programming, but this is something programmers might know, so... Has anyone run into this before? Perhaps someone knows how this [cmdline] tag works? Are there any other ways to add this dll to all users? (Apart from editing the registry manually that is.) Any insight would be greatly appreciated!
What you put in place to [cmdline] is determined by the DLL you're registering. regsvr32 will just pass that text to a function called DllInstall in the DLL. If you want to know what to pass, you must consult the documentation for this particular DLL.

Resources