Click here to Skip to main content
16,019,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am getting Attempted to read or write protected memory. This is often an indication that other memory is corrupt. while I am calling EnumWindows. Opening my vb.net from through main module
VB
'Globally declare
                 Declare Function EnumWindows Lib "user32" (ByVal x As CallBack, ByVal y As Integer) As Integer
                 Public Delegate Sub CallBack()

  'Function declared in Main module
        Public Sub AddProcessReply()

'Calling function

               Dim intAddressOf As Integer
               intAddressOf = EnumWindows(AddressOf AddProcessReply, 0)
               Ret = .Back(intAddressOf)               // Back function is VC++ function from vb.net 
i am passing function pointer but I am getting error

Thanks..
Posted
Updated 28-May-12 4:30am
v2
Comments
Sergey Alexandrovich Kryukov 28-May-12 11:53am    
First of all, why would you call EnumWindows?
--SA

1 solution

I'm not sure you really need to use P/Invoke (and when you do, you immediately loose platform compatibility which you have otherwise, even if you use some non-standard libraries like Forms, ADO.NET, etc.), but check it with this:
http://www.pinvoke.net/search.aspx?search=EnumWindows&namespace=[All][^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900