Hello all,
I'm making a wrapper DLL for my Windows API functions that I use a lot. Now anyone who has worked with windows API knows that probably 80% of the windows API calls use one or more handles as argument(s). Now I've read that sometimes GC will collect the IntPtr and then your PInvoke will fail.
I've got a few questions.

#1 Why/when use HandleRef Over IntPtr
#2 What is the correct method of declaring a HandleRef ( what is the wrapper ?)

And I have a few other questions.
#3 You can import a external function using the DLLImport Attribute or using a 'Declare' and 'lib' Which one is the best/correct ? (to me the DLLImport attribute looks so much more legit than the 'declare' and 'lib')
#4 I Want to create a Wrapper for SendMessage But It can have various return data types (and probably various argument datatypes) Is it correct If I just make the return type Object ? Or would I need to make a class just for SendMessage ?

EDIT #5 What is the difference between Intptr and a normal Integer ? it seems like they both just contain numeric data ?