Article ID: 149419 - Last Review: October 15, 2003 - Revision: 2.1 INFO: OLE Server Launched by OLE Client Gets System EnvironmentThis article was previously published under Q149419 SUMMARY
An OLE server that is launched by an OLE client in Windows NT will get the
SYSTEM environment and not the USER environment. This does not occur in
Windows 95 where the SYSTEM environment and the USER environment are the
same.
MORE INFORMATION
This behavior is by design and is because the OLE server is actually
started by the OLE service. However this can cause the server to work
differently when it is started by the user from the way it behaves when it
is started by an OLE client. For example, if the server loads a DLL using
LoadLibrary without the full path and the DLL is located in a directory in
the USER path but not in the SYSTEM path, the DLL will be found when the
server is run by the user but won't be found when the server is launched by
an OLE client. Many applications do not run into this problem because they
statically link to DLLs and those DLLs are in the same directory as the
.exe file. Many of the USER environment variables can be found as follows when the server is launched by OLE with the SYSTEM environment and this information can be used as a workaround to OLE's behavior: The PATH, INCLUDE, TEMP, and LIB environment variables can be found by looking in the registry under HKEY_CURRENT_USER\Environment. USERNAME can by found using GetUserName(). HOMEDRIVE & HOMEPATH can be found using NetGetUserInfo as follows: The server can determine if it was launched by OLE by looking for -Embedding or /Embedding in the command line arguments. With Service Pack 3, local OLE servers on NT 4 that are set to start under the "Launching User" identity (the default setting,) will inherit the USER environment. Note that this does not apply to servers set to start under a "RunAs" identity (either Interactive User or a specific user). Also it does not apply to remote servers, only to local machine activations. With this change, the default behavior for OLE servers (as far as inheriting environments is concerned) under NT4 becomes identical to that of Windows 95.
| Article Translations
|
Back to the top
