Discussion:
isapi app Can't write to HKLM
(too old to reply)
Jeremy
2008-03-13 23:47:34 UTC
Permalink
By commenting out all code and adding back in a line at a time, I believe
I've demonstrated that under vista and IIS7, at least on my installation, an
isapi app cannot write a registry entry to HKLM.

Here's the code that, when executed, hangs my dll: (notice that I've
commented out th3 showmessage already)

class procedure Tregbase.putReg(section,key,value: string);
begin
with tregistry.create do begin
RootKey:=HKEY_LOCAL_MACHINE;
try
openkey('SOFTWARE\myappname'+section,true);
WriteString(key,value);
CloseKey;
except
// on e: Exception Do ShowMessage(e.Message);
end;
destroy;
end;
end;
Rabatscher Michael
2008-03-14 12:04:25 UTC
Permalink
Post by Jeremy
By commenting out all code and adding back in a line at a time, I
believe I've demonstrated that under vista and IIS7, at least on my
installation, an isapi app cannot write a registry entry to HKLM.
Here's the code that, when executed, hangs my dll: (notice that I've
commented out th3 showmessage already)
class procedure Tregbase.putReg(section,key,value: string);
begin
with tregistry.create do begin
RootKey:=HKEY_LOCAL_MACHINE;
try
openkey('SOFTWARE\myappname'+section,true);
WriteString(key,value);
CloseKey;
except
// on e: Exception Do ShowMessage(e.Message);
end;
destroy;
end;
end;
I'm not that familiar with the IIS but AFAIK the executing threads run
on a fairly restricted user account. This accout does not allow writing
to HKLM. So I suggest you either use the HKCU key or global settings
file (like ini files)

kind regards
Mike
Jeremy
2008-03-14 16:27:55 UTC
Permalink
Post by Rabatscher Michael
I'm not that familiar with the IIS but AFAIK the executing threads run
on a fairly restricted user account. This accout does not allow writing to
HKLM. So I suggest you either use the HKCU key or global settings file
(like ini files)
kind regards
Mike
Yes, that's what I was afraid was the case. Life is complicated. In this
case, I'm trying to make existing windows app functionality available online
without duplication of code insofar as possible. So, I'd like to have a
setttings store that can work in both circumstances. I want something
user-independent, which means HKCU isn't good. On Vista, the app folder is
not a place to keep data, so that eliminates the exe location. That leaves
one of the shared document folders, I guess. I'll poke around & see if
there is a windows standard folder that qualifies as a place to put an ini.

There's also going to be the issue of c:\temp. I don't know if that is
available to the IIS user, but I'd guess not. So, I need to find a temp
file location that works for a windows app and also for an isapi app.

Mike, thanks.

Jeremy
Jeremy
2008-03-14 17:27:29 UTC
Permalink
Post by Jeremy
Yes, that's what I was afraid was the case. Life is complicated. In this
case, I'm trying to make existing windows app functionality available
online without duplication of code insofar as possible. So, I'd like to
have a setttings store that can work in both circumstances. I want
something user-independent, which means HKCU isn't good. On Vista, the
app folder is not a place to keep data, so that eliminates the exe
location. That leaves one of the shared document folders, I guess. I'll
poke around & see if there is a windows standard folder that qualifies as
a place to put an ini.
Ok, using CSIDL_COMMON_APPDATA, I've succeeded in creating an ini file on my
vista test machine. This constant translates into c:\programdata\ on vista
and C:\Documents and Settings\All Users on XP and earlier. Remains to be
seen if an isapi app running on win2k3 server can access the latter.
Rabatscher Michael
2008-03-15 11:05:13 UTC
Permalink
Post by Jeremy
Post by Rabatscher Michael
I'm not that familiar with the IIS but AFAIK the executing threads run
on a fairly restricted user account. This accout does not allow
writing to HKLM. So I suggest you either use the HKCU key or global
settings file (like ini files)
kind regards
Mike
Yes, that's what I was afraid was the case. Life is complicated. In
this case, I'm trying to make existing windows app functionality
available online without duplication of code insofar as possible. So,
I'd like to have a setttings store that can work in both circumstances.
I want something user-independent, which means HKCU isn't good.
Why not? These threads always run under the same user account (something
like IIS_USER ...) so there is no problem with different users.
The only problem is to change settings though....

kind regards
Mike
Jeremy
2008-03-15 18:38:22 UTC
Permalink
Post by Rabatscher Michael
.. I'm trying to make existing windows app functionality
available online without duplication of code insofar as possible. So,
I'd like to have a setttings store that can work in both circumstances.
I want something user-independent, which means HKCU isn't good.
Why not? These threads always run under the same user account (something
like IIS_USER ...) so there is no problem with different users.
Mike, my goal is to use the same code base in both an online app and a
windows app. The windows app is the one where HKCU isn't good. But anyway,
ini files solve the problem and also move in the direction of supporting
vista. Just counted 190 units in the windows app, which means converting
from reg to ini will take a little effort!

Jeremy
Rabatscher Michael
2008-03-16 09:31:41 UTC
Permalink
Post by Jeremy
Mike, my goal is to use the same code base in both an online app and a
windows app. The windows app is the one where HKCU isn't good.
Yes, then the ini file the most suitable solution I think.

kind regards
Mike

Loading...