Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
AnswerRe: urgent help pleasse [image processing , pointers , byte ] Pin
saurabh sahay10-Jun-09 11:50
saurabh sahay10-Jun-09 11:50 
QuestionHttpResponse Compression... ? Pin
Trapper-Hell10-Jun-09 5:54
Trapper-Hell10-Jun-09 5:54 
AnswerRe: HttpResponse Compression... ? Pin
Colin Angus Mackay10-Jun-09 6:15
Colin Angus Mackay10-Jun-09 6:15 
AnswerRe: HttpResponse Compression... ? Pin
saurabh sahay10-Jun-09 6:18
saurabh sahay10-Jun-09 6:18 
GeneralRe: HttpResponse Compression... ? Pin
Trapper-Hell10-Jun-09 6:25
Trapper-Hell10-Jun-09 6:25 
GeneralRe: HttpResponse Compression... ? Pin
saurabh sahay10-Jun-09 6:35
saurabh sahay10-Jun-09 6:35 
QuestionExtracting Repeating Table Data In a Web Part Pin
lday8610-Jun-09 5:42
lday8610-Jun-09 5:42 
Questionchanging the color and text of the label control dynamically from the retrieved values from the database Pin
praveenkumar_vittaboina10-Jun-09 4:58
praveenkumar_vittaboina10-Jun-09 4:58 
AnswerRe: changing the color and text of the label control dynamically from the retrieved values from the database Pin
Tom Deketelaere10-Jun-09 5:22
professionalTom Deketelaere10-Jun-09 5:22 
Questioncrystal reports problem after installing the application. Pin
praveenkumar_vittaboina10-Jun-09 4:57
praveenkumar_vittaboina10-Jun-09 4:57 
AnswerRe: crystal reports problem after installing the application. Pin
Tom Deketelaere10-Jun-09 5:19
professionalTom Deketelaere10-Jun-09 5:19 
QuestionChecking a registry key exists Pin
Martin3108810-Jun-09 4:21
Martin3108810-Jun-09 4:21 
AnswerRe: Checking a registry key exists Pin
Henry Minute10-Jun-09 4:45
Henry Minute10-Jun-09 4:45 
GeneralRe: Checking a registry key exists Pin
Martin3108810-Jun-09 4:57
Martin3108810-Jun-09 4:57 
GeneralRe: Checking a registry key exists Pin
Henry Minute10-Jun-09 5:07
Henry Minute10-Jun-09 5:07 
GeneralRe: Checking a registry key exists Pin
Martin3108810-Jun-09 5:35
Martin3108810-Jun-09 5:35 
GeneralRe: Checking a registry key exists Pin
Henry Minute10-Jun-09 6:16
Henry Minute10-Jun-09 6:16 
I do not use the registry any more, or very rarely, so I have had to go back and look at some of my old code.

The only obviously different things that I used to do is as below.

string myAppSaveDataSubKey = @"software\MyApp\SaveData"; <=== use a variable. saves having to keep typing it in and possible typos
using (RegistryKey MyRegKey = Registry.LocalMachine.OpenSubKey(myAppSaveDataSubKey)) <== using 'using' saves having to remember 'close'
{
    if (MyRegKey == null)  <=========== Check == null instead of != null
    {
        RegistryKey CreateMyRegKey = Registry.LocalMachine.CreateSubKey(myAppSaveDataSubKey);
        CreateMyRegKey.SetValue("Currency", 0);
        string OptCurrency = "0";
    }
    else
    {
        string OptCurrency = MyRegKey.GetValue("Currency").ToString(); <== you need to load OptCurrency anyway so don't 'else' it
    }
}


which used to work OK for me.

The only other thing you might consider is to use CreateSubKey instead of OpenSubKey. This has the advantage of creating the subkey if it doesn't exist, and simply opening it for writing if it does.

Hope some of this is useful. Smile | :)

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

GeneralRe: Checking a registry key exists Pin
Martin3108810-Jun-09 6:28
Martin3108810-Jun-09 6:28 
GeneralRe: Checking a registry key exists Pin
Martin3108810-Jun-09 23:57
Martin3108810-Jun-09 23:57 
Questioncheckedlistbox - save checked items for future run Pin
havejeet10-Jun-09 3:50
havejeet10-Jun-09 3:50 
AnswerRe: checkedlistbox - save checked items for future run Pin
Manas Bhardwaj10-Jun-09 3:51
professionalManas Bhardwaj10-Jun-09 3:51 
AnswerRe: checkedlistbox - save checked items for future run Pin
Rajesh R Subramanian10-Jun-09 4:01
professionalRajesh R Subramanian10-Jun-09 4:01 
Questiontaking null instead of value Pin
KIDYA10-Jun-09 3:01
KIDYA10-Jun-09 3:01 
AnswerRe: taking null instead of value Pin
Tom Deketelaere10-Jun-09 3:05
professionalTom Deketelaere10-Jun-09 3:05 
AnswerRe: taking null instead of value Pin
Colin Angus Mackay10-Jun-09 5:04
Colin Angus Mackay10-Jun-09 5:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.