Click here to Skip to main content
15,922,696 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: PRINT FROM DATA READER ON MULTIPLE PAGES Pin
Silva_A14-May-09 8:45
Silva_A14-May-09 8:45 
QuestionHelp - Finding 3rd Point on Circle Pin
cyndy_northrup11-May-09 9:53
cyndy_northrup11-May-09 9:53 
AnswerRe: Help - Finding 3rd Point on Circle Pin
Luc Pattyn11-May-09 10:43
sitebuilderLuc Pattyn11-May-09 10:43 
AnswerRe: Help - Finding 3rd Point on Circle Pin
DidiKunz12-May-09 21:54
DidiKunz12-May-09 21:54 
QuestionCrystal Report : Group Header .... Pin
sybux200011-May-09 8:39
sybux200011-May-09 8:39 
AnswerRe: Crystal Report : Group Header .... Pin
David Mujica11-May-09 10:02
David Mujica11-May-09 10:02 
GeneralRe: Crystal Report : Group Header .... Pin
sybux200013-May-09 7:02
sybux200013-May-09 7:02 
QuestionGetting handle to an open Registry Key in VB 2008? Pin
johnfgh11-May-09 7:53
johnfgh11-May-09 7:53 
Hi,

I'm pretty new to VB, but have been writing a program using VB 2008 Express. I have a section of code that will compile perfectly using VB Studio 2003, but it throws a InvalidCast Exception under VB 2005/2008. The code throws an Invalid Cast exception at [I]KeyHandle = e(field.GetValue(KeyToMonitor)[/I] line below, and as far as I can tell it is because the variable Field is passing the string Microsoft.Win32.SafeHandles.SafeRegistryHandle rather than an integer. Is this because of safe keys in VB 2005 and 2008?

If so, would anyone be able to tell me how to call the handle of the registry key opened in a way compatible with Safe Keys? I'm using the code to notify when a registry key is changed using RegNotifyChangeKeyValue.

<br />
Private Function WaitForChange() As Boolean<br />
        Dim notifyEvent As New Threading.AutoResetEvent(False)<br />
        Dim KeyHandle As IntPtr<br />
        Dim KeyToMonitor As RegistryKey<br />
        KeyToMonitor = Registry.CurrentUser.OpenSubKey("Software\Microsoft\MediaPlayer\CurrentMetadata", False)<br />
        Dim regKeyType As Type = GetType(RegistryKey)<br />
        Dim field As System.Reflection.FieldInfo<br />
        field = regKeyType.GetField("hkey", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)<br />
        KeyHandle = CType(field.GetValue(KeyToMonitor), IntPtr)<br />
<br />
        Dim err As Integer<br />
        err = NativeMethods.RegNotifyChangeKeyValue(KeyHandle, _<br />
            True, NotifyFilterFlags.REG_NOTIFY_CHANGE_ATTRIBUTES _<br />
            Or NotifyFilterFlags.REG_NOTIFY_CHANGE_LAST_SET _<br />
            Or NotifyFilterFlags.REG_NOTIFY_CHANGE_NAME _<br />
            Or NotifyFilterFlags.REG_NOTIFY_CHANGE_SECURITY, _<br />
            notifyEvent.Handle, True)<br />
<br />
        If err = 0 Then<br />
            notifyEvent.WaitOne()<br />
            RaiseEvent KeyChanged(CObj(Me), New EventArgs())<br />
            Return True<br />
        Else<br />
            Debug.WriteLine(err)<br />
            Return False<br />
        End If<br />
    End Function<br />

Question[Message Deleted] Pin
oxela11-May-09 7:42
oxela11-May-09 7:42 
AnswerRe: how to connect the buissnes layer with other layers Pin
nlarson1111-May-09 9:31
nlarson1111-May-09 9:31 
AnswerRe: how to connect the buissnes layer with other layers Pin
Mycroft Holmes11-May-09 18:11
professionalMycroft Holmes11-May-09 18:11 
AnswerRe: how to connect the buissnes layer with other layers Pin
Dave Kreskowiak11-May-09 18:52
mveDave Kreskowiak11-May-09 18:52 
AnswerRe: how to connect the buissnes layer with other layers Pin
oxela14-May-09 7:18
oxela14-May-09 7:18 
Questiondatatable in VB.net Pin
Pankaj-codeproject11-May-09 6:36
Pankaj-codeproject11-May-09 6:36 
AnswerRe: datatable in VB.net Pin
Dave Kreskowiak11-May-09 6:50
mveDave Kreskowiak11-May-09 6:50 
Questionmybase.new Pin
sabr4911-May-09 6:18
sabr4911-May-09 6:18 
AnswerRe: mybase.new Pin
Luc Pattyn11-May-09 6:27
sitebuilderLuc Pattyn11-May-09 6:27 
Questionsmooth motion Pin
TheMrProgrammer11-May-09 6:11
TheMrProgrammer11-May-09 6:11 
AnswerRe: smooth motion Pin
Dave Kreskowiak11-May-09 6:48
mveDave Kreskowiak11-May-09 6:48 
GeneralRe: smooth motion Pin
TheMrProgrammer11-May-09 7:06
TheMrProgrammer11-May-09 7:06 
GeneralRe: smooth motion Pin
Luc Pattyn11-May-09 7:33
sitebuilderLuc Pattyn11-May-09 7:33 
Questionhow to view orginal address format in textbox Pin
JC.KaNNaN11-May-09 1:37
JC.KaNNaN11-May-09 1:37 
AnswerRe: how to view orginal address format in textbox Pin
dan!sh 11-May-09 1:54
professional dan!sh 11-May-09 1:54 
GeneralRe: how to view orginal address format in textbox Pin
JC.KaNNaN11-May-09 2:29
JC.KaNNaN11-May-09 2:29 
AnswerRe: how to view orginal address format in textbox Pin
riced11-May-09 6:01
riced11-May-09 6:01 

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.