Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1898416
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:45:44+00:00 2026-05-17T06:45:44+00:00

This time i’m tring to work with registry values and so i’m using the

  • 0

This time i’m tring to work with registry values and so i’m using the following code

Private Function RegKeyExists(ByVal hKey As Long, ByVal sKeyPath As String) As Boolean

      Dim lResult As Long
      Dim hSubkey As Long

      lResult = RegOpenKeyEx(hKey, sKeyPath, 0, KEY_EXECUTE, hSubkey)
      ' Determine if handle is valid
      If hSubkey <> 0 Then
           RegKeyExists = True
           RegCloseKey(hKey)
      End If

 End Function

and i’m calling this function from the folloing line

RegKeyExists(HKEY_LOCAL_MACHINE, "\Software\OTA\Elefsina\Vechicle")

Of course the path is not exists and so i’m expecting tho receive FALSE from the Function, but intead of that the program is stoped inside the function and gives me an error of

"System.AccessViolationException was unhandled
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=vehicles
  StackTrace:
       at vehicles.vehicleformmain.RegOpenKeyEx(Int64 hKey, String& lpSubKey, Int64 ulOptions, Int64 samDesired, Int64 phkResult)
       at vehicles.vehicleformmain.RegKeyExists(Int64 hKey, String sKeyPath) in D:\Work\ADATA\New2010Projects\OTA\Elefsina\Projects\vehicles\vehicles\vehicleformmain.vb:line 95
       at vehicles.vehicleformmain.vehicleformmain_Load(Object sender, EventArgs e) in D:\Work\ADATA\New2010Projects\OTA\Elefsina\Projects\vehicles\vehicles\vehicleformmain.vb:line 106
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at vehicles.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
  InnerException: "

I can’t understand why is that error occured and what i have to do
is there anybody to assist me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:45:44+00:00Added an answer on May 17, 2026 at 6:45 am

    There is no need to use Windows API here… the .NET framework provides means for accessing the registry:

    Dim regKey = Registry.LocalMachine.OpenSubKey("Software\OTA\Elefsina\Vechicle", False)
    
    If regKey Is Nothing Then
        ''# Key doesn't exist
    
    Else
        ''# Key exists -- do something with it, if you want, and then close it
    
        regKey.Close()
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this time I have a page which will load different kinds of file formats,
Pretty simple question this time around. I have an application that communicates with another
I got really close this time ;) Bellow there is : my xsl script
It's time for another 'how do i do this in c++ without loosing my
I am doing some uploading stuff in iphone this time. This is absolutely first
I'm working already a good time with the .net framework. In this time there
I've got a php backend which delivers a time (e.g. '07:00:00'). This time is
I have never been good at playing with pointers in C. But this time
I can scan and get the Wifi list in iPhoneOS4.0. At this time, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.