6 Replies - 637 Views - Last Post: 11 February 2010 - 10:02 AM Rate Topic: -----

#1 wads  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 11-January 10

System registry referencing

Posted 11 February 2010 - 05:59 AM

Hi,

I have a program that write a key to the HKEY_CURRENT_USER (it stores an email address there & I call it later to send to that address)

On form load a dialog opens & asks for email address.

Everything OK on testing the program, when I deploy the application the dialog doesn't open. I assume this has got to be something to do with what references I add.

I have added system & system32 but still doesn't work. The code I have is below.

Can anyone tell me what references to add & if/what to copy to output directory.

I'm using VBExpress 2008

I have added:-

Public Const c_strKeyName As String = "HKEY_CURRENT_USER\Software\TimWadSoftware\ServiceReport\"


  Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        My.Settings.Reload()

        '------------------CREATE SERVICE REPORTS FOLDER IN C: DRIVE FOR STORING WORD DOCUMENTS--------------------

        SerRepLoc = Environ$("USERPROFILE") & "\My Documents\Service Reports\"
        If My.Computer.FileSystem.DirectoryExists(SerRepLoc) = False Then
            My.Computer.FileSystem.CreateDirectory(SerRepLoc)
        End If

        '-------------------TO GET SENDERS EMAIL ADDRESS-----------------------------------

        MailAddress = CStr(My.Computer.Registry.GetValue(c_strKeyName, "EmailAddress", " "))
        If MailAddress = " " Then
            frmMailAdd.ShowDialog()



Is This A Good Question/Topic? 0
  • +

Replies To: System registry referencing

#2 demausdauth  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 638
  • Joined: 03-February 10

Re: System registry referencing

Posted 11 February 2010 - 06:35 AM

It doesn't seem to have anything to do with the references. What it looks like is that the registry key doesn't exist and so the form can't open. When you deployed the application did it create the registry key?
Was This Post Helpful? 0
  • +
  • -

#3 wads  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 11-January 10

Re: System registry referencing

Posted 11 February 2010 - 07:00 AM

View Postdemausdauth, on 11 February 2010 - 05:35 AM, said:

It doesn't seem to have anything to do with the references. What it looks like is that the registry key doesn't exist and so the form can't open. When you deployed the application did it create the registry key?


No, it didn't. As you can see on the form loading, if the string 'MailAddress' is empty i.e. no key created, it then opens a dialog box that has the following code & I thought it then created the key?

Is that not correct?
    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        My.Computer.Registry.SetValue(c_strKeyName, "EmailAddress", tbEmailAdd.Text)
        Me.Close()
    End Sub
    Private Const c_strKeyName As String = "HKEY_CURRENT_USER\Software\TimWadSoftware\ServiceReport\"
    Private Sub frmMailAdd_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Visible = False
        Me.StartPosition = FormStartPosition.CenterScreen
        Label2.Text = "To enable a copy of your service reports to be sent to your own mailbox" & vbCrLf & "enter your work email address below"
    End Sub

Was This Post Helpful? 0
  • +
  • -

#4 Bort  Icon User is offline

  • Ill-informed Mongoloid
  • member icon

Reputation: 396
  • Posts: 2,923
  • Joined: 18-September 06

Re: System registry referencing

Posted 11 February 2010 - 07:17 AM

No, it is not creating the registry key, only trying to set the value.

Take a look at my tutorial here on editing the registry. It should point you in the right direction :)
Was This Post Helpful? 0
  • +
  • -

#5 wads  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 11-January 10

Re: System registry referencing

Posted 11 February 2010 - 08:22 AM

Great thanks for your help.

I am still a bit confused, why does it set the value in my registry (folder & values) yet won't on others that used the deployed app?
Was This Post Helpful? 0
  • +
  • -

#6 Bort  Icon User is offline

  • Ill-informed Mongoloid
  • member icon

Reputation: 396
  • Posts: 2,923
  • Joined: 18-September 06

Re: System registry referencing

Posted 11 February 2010 - 09:20 AM

I suspect because during testing you created the registry entries it needs, so all it is doing is updating that. On the other systems, it will be trying to update a registry key that doesn't exist.
Was This Post Helpful? 0
  • +
  • -

#7 wads  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 11-January 10

Re: System registry referencing

Posted 11 February 2010 - 10:02 AM

All working fine now

Thanks for your help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1