473,785 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Registry Programming in Windows Service

Hi all,

in my service i added my Registry Programming code,am facing with a problem
which am not able to rectify it..the problem is , in the service, the program
gets hanged and doesnt move after Registry is accessed..that is before
registry code,everything works and once u access regitry it doesnt!......ev en
Messagebox isnot working!..

the code is as follows,

/*************** ***********Code starts here*********** ********/
RegistryKey
pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
pRegKey->SetValue("VAL" ,"1");
pRegKey.Close() ;

pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
object result=pRegKey->GetValue("VAL" );
MessageBox.Show (result.ToStrin g());
pRegKey.Close() ;
/*************** ***********Code starts here*********** ********/

i would be happy if someone could help me out..

thanks in advance...

with regards,
C.C.Chakkaradee p
Nov 16 '05 #1
5 2713
A MessageBox typically won't show from a Service - it's running with a
different account and probably wasn't installed to Interact with Desktop.
Your Service thread might just be crashing too if those keys/data items are
missing - I think the process still stays running so it looks like a hang.
--
Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:EF******** *************** ***********@mic rosoft.com...
Hi all,

in my service i added my Registry Programming code,am facing with a
problem
which am not able to rectify it..the problem is , in the service, the
program
gets hanged and doesnt move after Registry is accessed..that is before
registry code,everything works and once u access regitry it
doesnt!......ev en
Messagebox isnot working!..

the code is as follows,

/*************** ***********Code starts here*********** ********/
RegistryKey
pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
pRegKey->SetValue("VAL" ,"1");
pRegKey.Close() ;

pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
object result=pRegKey->GetValue("VAL" );
MessageBox.Show (result.ToStrin g());
pRegKey.Close() ;
/*************** ***********Code starts here*********** ********/

i would be happy if someone could help me out..

thanks in advance...

with regards,
C.C.Chakkaradee p

Nov 16 '05 #2
Chakkaradeep,

What is the account that the service is running under? Is it possible
that the account doesn't have rights to the registry? If you set the
service up to run under an admin account, does it work?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:EF******** *************** ***********@mic rosoft.com...
Hi all,

in my service i added my Registry Programming code,am facing with a
problem
which am not able to rectify it..the problem is , in the service, the
program
gets hanged and doesnt move after Registry is accessed..that is before
registry code,everything works and once u access regitry it
doesnt!......ev en
Messagebox isnot working!..

the code is as follows,

/*************** ***********Code starts here*********** ********/
RegistryKey
pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
pRegKey->SetValue("VAL" ,"1");
pRegKey.Close() ;

pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
object result=pRegKey->GetValue("VAL" );
MessageBox.Show (result.ToStrin g());
pRegKey.Close() ;
/*************** ***********Code starts here*********** ********/

i would be happy if someone could help me out..

thanks in advance...

with regards,
C.C.Chakkaradee p

Nov 16 '05 #3
Your service runs in a secured non interactive non visible
desktop/winstation. Whenever you execute MessageBox.Show the MessageBox is
not visible and no-one can press the OK button and your service appears to
hang.
Remove the MessageBox.Show and try again.

Willy.

"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:EF******** *************** ***********@mic rosoft.com...
Hi all,

in my service i added my Registry Programming code,am facing with a
problem
which am not able to rectify it..the problem is , in the service, the
program
gets hanged and doesnt move after Registry is accessed..that is before
registry code,everything works and once u access regitry it
doesnt!......ev en
Messagebox isnot working!..

the code is as follows,

/*************** ***********Code starts here*********** ********/
RegistryKey
pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
pRegKey->SetValue("VAL" ,"1");
pRegKey.Close() ;

pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
object result=pRegKey->GetValue("VAL" );
MessageBox.Show (result.ToStrin g());
pRegKey.Close() ;
/*************** ***********Code starts here*********** ********/

i would be happy if someone could help me out..

thanks in advance...

with regards,
C.C.Chakkaradee p

Nov 16 '05 #4
Hi all,

i haev enabled Interaction with Desktop option in the Program Code
itself......Reg istry code is working in other functions but only in this code
which is in another function is not working........ .so am confused...beco z if
it working in one part o my code,it should work at another part also provided
all my syntax and usage are correct.....as said in MSDN i have closed the
RegistryKey so that my work is accomplished..t hen also in this particular
code part whihc i have written above does not work!!!..

thanks in advance..

with regards,
C.C.Chakkaradee p

"Willy Denoyette [MVP]" wrote:
Your service runs in a secured non interactive non visible
desktop/winstation. Whenever you execute MessageBox.Show the MessageBox is
not visible and no-one can press the OK button and your service appears to
hang.
Remove the MessageBox.Show and try again.

Willy.

"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:EF******** *************** ***********@mic rosoft.com...
Hi all,

in my service i added my Registry Programming code,am facing with a
problem
which am not able to rectify it..the problem is , in the service, the
program
gets hanged and doesnt move after Registry is accessed..that is before
registry code,everything works and once u access regitry it
doesnt!......ev en
Messagebox isnot working!..

the code is as follows,

/*************** ***********Code starts here*********** ********/
RegistryKey
pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
pRegKey->SetValue("VAL" ,"1");
pRegKey.Close() ;

pRegKey=Registr y.LocalMachine. OpenSubKey("Sof tware\\Software \\MyKey");
object result=pRegKey->GetValue("VAL" );
MessageBox.Show (result.ToStrin g());
pRegKey.Close() ;
/*************** ***********Code starts here*********** ********/

i would be happy if someone could help me out..

thanks in advance...

with regards,
C.C.Chakkaradee p


Nov 16 '05 #5

"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:31******** *************** ***********@mic rosoft.com...
Hi all,

i haev enabled Interaction with Desktop option in the Program Code
itself......Reg istry code is working in other functions but only in this
code
which is in another function is not working........ .so am confused...beco z
if
it working in one part o my code,it should work at another part also
provided
all my syntax and usage are correct.....as said in MSDN i have closed the
RegistryKey so that my work is accomplished..t hen also in this particular
code part whihc i have written above does not work!!!..


What exactly is not working, any error code exceptions? ( you don't seem to
need try/catch blocks)
Is the registry path correct?

Time to attach a debugger and step through your code I'm affraid, if you
can't supply us more info.

Willy.

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3223
by: merc | last post by:
C++ Guru's.. I need some help please. I've been reading the C++ in 21 days by James Liberty. Currently I'm on Chapter 7 (looping). This knowledge doesn't have anything really to do with my question; it's more to show you that I'm a rookie learning C++. I have an opportunity to write a simple application for my work and I'd like to write my very first non-book tutorial application.
2
5910
by: René Beumer | last post by:
I am trying to install a windows service written in .net 2003 on my Windows 2000 computer. I have followed the walkthru given in msdn but the service fails to install with 'requested registry access is not allowed' (using both InstallUtil or by creating an installer). I have tracked the registry access failure using RegMon and found that it fails on
2
15076
by: Brian Campbell | last post by:
Gretings... I have written a Windows Service that accesses a Web Service. Both run fine on my development machine.... After installing both the Windows Service and Web Service on my staging server, I get the following error...
3
12504
by: caldera | last post by:
Hi, I write a windows service. In that service I create a new subkey for registry. But service install is call CreateSubKey() the program throw an exception to the event log said that Cannot write to the registry key. What can cause to this message. Also I want to create sub key from my asp.net project. How can I authoritize to write a new for the web application for the registry. Thanks for your answers.
10
8207
by: Clint | last post by:
Hey all - I'm having a really confusing problem concerning a web service. Right now, I have an application that needs to call a web service that does nothing but return "true" (this will obviously change once the program's fully built to actually do something, but for testing, it works). The only code I added to the service is below:
21
10835
by: Kevin Swanson | last post by:
I'm attempting some remote registry manipulation via C#. I've written a test app to simply grab a specified key from a specified hive on a specified machine. The call to OpenSubKey is throwing System.SecurityException. Also of note: Sitting at my local box, I can open regedit and connect to the remote registry. I see three hives: _CLASSES_ROOT, _LOCAL_MACHINE, and _USERS. I can open all but HKEY_LOCAL_MACHINE. When I try to expand that...
3
5077
by: Ahmad Jalil Qarshi | last post by:
Hi! I am developing an application in C# as a windows NT Service. This application needs to check for eventlog using EventLog.Exists("System") But unfortunately it generates exception "Requested registry access is not allowed."
6
1639
by: vovan | last post by:
I'm asking for help one more time. Below are 2 procedures. The first one is used in VB 2005 Windows Form project. It works fine on XP, Vista. Private Sub RegistryReadingTest() Try Dim f As New RegistryPermission(RegistryPermissionAccess.Read, _ "HKEY_LOCAL_MACHINE\SOFTWARE\SRS Enterprises\Coordinator\Settings") f.Demand()
3
1648
by: thephatp | last post by:
BLUF: I need to build up the actual %TEMP% path for all users methodically using values in the registry, and I need to do this both by the current user AND as a service will do this running as "Local System." Thus, I can't rely on it always being ...\<Username>\Local Settings\Temp. So, this partially applies to C#, because I'll need to do this in C# code. But, I think I already know how to do it. What I don't know is where to find...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.