Microsoft KB Archive/259012

= PRB: Regsvr32 May Register COM In-Process Server from Different Directory =

Article ID: 259012

Article Last Modified on 2/23/2007

-

APPLIES TO


 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition
 * Microsoft Windows NT Advanced Server 3.1
 * Microsoft Windows NT Server 4.0 Standard Edition

-



This article was previously published under Q259012



SYMPTOMS
If you have multiple copies of your Component Object Model (COM) dynamic-link library (DLL) in different folders, when you run Regsvr32 from the directory where the DLL is located, the Regsvr32 utility registers the DLL from different locations depending on which version of Microsoft Windows you are running. On Windows 2000-based computers, Regsvr32 registers the DLL from the directory where Regsvr32 resides. However, on Windows NT-based computers, Regsvr32 registers the DLL from the current directory.

For example:


 * 1) Regsvr32.exe is located in C:\WinNT\System32.Your ActiveX/COM DLL (Test.dll) is located in C:\WinNT\System32 and C:\MyProgram.Your current directory is C:\MyProgram.At a command prompt, type regsvr32 test.dll to register Test.dll.
 * 2) Your ActiveX/COM DLL (Test.dll) is located in C:\WinNT\System32 and C:\MyProgram.Your current directory is C:\MyProgram.At a command prompt, type regsvr32 test.dll to register Test.dll.
 * 3) Your current directory is C:\MyProgram.At a command prompt, type regsvr32 test.dll to register Test.dll.
 * 4) At a command prompt, type regsvr32 test.dll to register Test.dll.

On Windows 2000, Regsvr32 registers the DLL in C:\WinNT\System32. On Windows NT 4.0, Regsvr32 registers the DLL in C:\MyProgram.



CAUSE
To register a COM DLL, the Regsvr32 utility uses the following syntax with the LoadLibraryEx function: LoadLibraryEx(lpFileName,NULL,LOAD_WITH_ALTERED_SEARCH_PATH) If you pass a partial file name (that is, not a fully qualified path) to this function instead of using the altered search path strategy, LoadLibraryEx uses the standard search path strategy to load the DLL. The standard search path strategy searches for a file in the following sequence:


 * 1) The directory from which the application is loaded.The current directory.
 * 2) The current directory.

Thus, on Windows 2000, Regsvr32 registers the DLL in C:\Winnt\System32, which is the directory where Regsvr32 resides. However, on Windows NT 4.0, LoadLibraryEx does not enforce a fully qualified path while it uses LOAD_WITH_ALTERED_SEARCH_PATH because of a bug in LoadLibraryEx. Because a fully qualified path is not passed to the function, LoadLibraryEx does not know where the specified DLL is located and cannot start the search at &quot;specified path&quot;. Thus, LoadLibraryEx starts the search at the current directory, and the DLL in the current directory is loaded.



RESOLUTION
To register the appropriate DLL in Windows 2000 and Windows NT, pass the fully qualified path of the DLL as a parameter to Regsvr32.

Keywords: kbinprocsvr kbnofix kbprb kbregistry KB259012

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.