473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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!......even
Messagebox isnot working!..

the code is as follows,

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

pRegKey=Registry.LocalMachine.OpenSubKey("Software \\Software\\MyKey");
object result=pRegKey->GetValue("VAL");
MessageBox.Show(result.ToString());
pRegKey.Close();
/**************************Code starts here*******************/

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

thanks in advance...

with regards,
C.C.Chakkaradeep
Nov 16 '05 #1
5 2695
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

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.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!......even
Messagebox isnot working!..

the code is as follows,

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

pRegKey=Registry.LocalMachine.OpenSubKey("Software \\Software\\MyKey");
object result=pRegKey->GetValue("VAL");
MessageBox.Show(result.ToString());
pRegKey.Close();
/**************************Code starts here*******************/

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

thanks in advance...

with regards,
C.C.Chakkaradeep

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.com

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.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!......even
Messagebox isnot working!..

the code is as follows,

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

pRegKey=Registry.LocalMachine.OpenSubKey("Software \\Software\\MyKey");
object result=pRegKey->GetValue("VAL");
MessageBox.Show(result.ToString());
pRegKey.Close();
/**************************Code starts here*******************/

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

thanks in advance...

with regards,
C.C.Chakkaradeep

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.

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.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!......even
Messagebox isnot working!..

the code is as follows,

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

pRegKey=Registry.LocalMachine.OpenSubKey("Software \\Software\\MyKey");
object result=pRegKey->GetValue("VAL");
MessageBox.Show(result.ToString());
pRegKey.Close();
/**************************Code starts here*******************/

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

thanks in advance...

with regards,
C.C.Chakkaradeep

Nov 16 '05 #4
Hi all,

i haev enabled Interaction with Desktop option in the Program Code
itself......Registry code is working in other functions but only in this code
which is in another function is not working.........so am confused...becoz 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..then also in this particular
code part whihc i have written above does not work!!!..

thanks in advance..

with regards,
C.C.Chakkaradeep

"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.

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.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!......even
Messagebox isnot working!..

the code is as follows,

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

pRegKey=Registry.LocalMachine.OpenSubKey("Software \\Software\\MyKey");
object result=pRegKey->GetValue("VAL");
MessageBox.Show(result.ToString());
pRegKey.Close();
/**************************Code starts here*******************/

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

thanks in advance...

with regards,
C.C.Chakkaradeep


Nov 16 '05 #5

"Chakkaradeep" <Ch**********@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
Hi all,

i haev enabled Interaction with Desktop option in the Program Code
itself......Registry code is working in other functions but only in this
code
which is in another function is not working.........so am confused...becoz
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..then 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
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...
2
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...
2
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...
3
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...
10
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...
21
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...
3
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...
6
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.