ExpandEnvironmentStrings 
Author Message
 ExpandEnvironmentStrings

The Win API function ExpandEnvironmentStrings does not seem to work on NT
Server machine although it does on a Win2000 machine.  I don't why this is.
Any suggestions?


Sun, 11 Sep 2005 22:39:23 GMT  
 ExpandEnvironmentStrings

Quote:
>The Win API function ExpandEnvironmentStrings does not seem to work on NT
>Server machine although it does on a Win2000 machine.  I don't why this is.

The docs say it's supported back to Windows 95 - so it should work
under NT4.

Do you have a small code example of what doesn't work for you under
NT4?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Mon, 12 Sep 2005 01:37:51 GMT  
 ExpandEnvironmentStrings
static void ResolveEnvironmentVars(CString &src)
{
  char result[256];
  if (ExpandEnvironmentStrings(src,result,sizeof(result))!=0)
    src = result;

Quote:
}

In my case ExpandEnvironmentStrings does not replace the substring
'%LOGONSERVER' that is passed in src.

Is this a Microsoft bug?  I found some stuff at
http://support.microsoft.com/default.aspx?scid=KB;en-us;q183495


Quote:
> >The Win API function ExpandEnvironmentStrings does not seem to work on NT
> >Server machine although it does on a Win2000 machine.  I don't why this
is.

> The docs say it's supported back to Windows 95 - so it should work
> under NT4.

> Do you have a small code example of what doesn't work for you under
> NT4?

> Dave
> --
> MVP VC++ FAQ: http://www.mvps.org/vcfaq



Mon, 12 Sep 2005 06:30:19 GMT  
 ExpandEnvironmentStrings

Quote:
>In my case ExpandEnvironmentStrings does not replace the substring
>'%LOGONSERVER' that is passed in src.

>Is this a Microsoft bug?  I found some stuff at
>http://support.microsoft.com/default.aspx?scid=KB;en-us;q183495

Sounds like it - have you tried the suggested resolution?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq



Mon, 12 Sep 2005 08:54:11 GMT  
 ExpandEnvironmentStrings
What does GetLastError() report?  Also, I believe that the variable must be
surrounded by % characters.


Quote:
> static void ResolveEnvironmentVars(CString &src)
> {
>   char result[256];
>   if (ExpandEnvironmentStrings(src,result,sizeof(result))!=0)
>     src = result;
> }

> In my case ExpandEnvironmentStrings does not replace the substring
> '%LOGONSERVER' that is passed in src.

> Is this a Microsoft bug?  I found some stuff at
> http://support.microsoft.com/default.aspx?scid=KB;en-us;q183495



Mon, 12 Sep 2005 16:05:34 GMT  
 ExpandEnvironmentStrings
It seems to be a security/permissions issue.  This bit of code is executed
from a COM object.  The COM object is created by an NT Service.  The NT
Service is run under a username who is a local administrator but not
Administrator.

I have tried getenv and logging the return strings to a log file.
GetLastError() does not report any error.  Running the same thing on my
machine, which is Win2k, works fine but I am logged as myself as a local
administrator.

The NT Service does not seem to have an environment.  The only way round
this problem is getting the logonserver name from the registry -
HKEY_CURRENT_USER\Volatile Environment\LOGONSERVER.



Quote:
> What does GetLastError() report?  Also, I believe that the variable must
be
> surrounded by % characters.



> > static void ResolveEnvironmentVars(CString &src)
> > {
> >   char result[256];
> >   if (ExpandEnvironmentStrings(src,result,sizeof(result))!=0)
> >     src = result;
> > }

> > In my case ExpandEnvironmentStrings does not replace the substring
> > '%LOGONSERVER' that is passed in src.

> > Is this a Microsoft bug?  I found some stuff at
> > http://support.microsoft.com/default.aspx?scid=KB;en-us;q183495



Tue, 13 Sep 2005 07:10:27 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. ExpandEnvironmentStrings implementation

2. How to get system folder by ExpandEnvironmentStrings()?

3. How to get system folder by ExpandEnvironmentStrings()?

 

 
Powered by phpBB® Forum Software