tags:

views:

10

answers:

2
Private Declare Function CascadeWindowsNative Lib "user32" Alias "CascadeWindows" ( _
   ByVal hwndParent As Long, _
   ByVal wHow As Long, _
   ByVal lpRect As Long, _
   ByVal cKids As Long, _ 
   ByVal lpkids As Long) As Integer

calling:

CascadeWindowsNative(Nothing, &H4, 0, 0, 0)
+1  A: 

The primary issues here is that you are passing handle values with the Long type. That is incorrect, they need to be passed via the IntPtr type. Under the hook handles are essentially pointers and vary in size based on whether or not the process is 32 or 64 bit.

I'm not familiar with that API so I don't know if the rest of the parameters are correct or not. The sample code on PInvoke.Net suggests that several of these should be typed to something other than Long

What's likely happening here is one of the computers you're running is 64 bit and the pinvoke call is working and the other is 32 bit and the call is failing due to the inherent stack imbalance.

JaredPar
you are right. The signature was incorrect
Microgen
A: 

This works:

Private Declare Function CascadeWindowsNative Lib "user32" Alias "CascadeWindows" (ByVal hwndParent As IntPtr,
                                                                                   ByVal wHow As UInt32,
                                                                                   ByVal lpRect As IntPtr,
                                                                                   ByVal cKids As UInt32,
                                                                                   ByVal lpkids() As IntPtr) As Integer
Microgen