-
My 2 cents!
My favorite APIs:
Code:
'Gives you a lot of control!
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'System manipulation!
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Public Declare Function GetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
'Memory control!
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Sub ZeroMemory Lib "KERNEL32" Alias "RtlMoveMemory" (dest As Any, ByVal numBytes As Long)
What can you say? I'm a control freak.
Favorite intrinsic functions:
Code:
lPos = InStr()
lLength = Len()
Remainder = X Mod Y 'operator
Favorite properies:
Code:
[Object].hWnd
[Object].hDC
App.hInstance
App.Path
-
what does ZeroMemory do???
My fav. property is
:D
-
I think it clears memory in some way?
-
From MSDN:
The ZeroMemory function fills a block of memory with zeros.
I like this function! :D
-
Why would you use that? :)
-
If you were cynical: To torture my victims everywhere!
If you weren't: To clean memory leftovers.
-
I was half cynical.
But when do you get memory leftovers?
Does every programmer deal with that or only when you do certain things?
-
*AHEM*
Here's the correct declaration: :rolleyes:
Code:
Declare Sub ZeroMemory Lib "kernel32" Alias "RtlZeroMemory" (pDest As Any, ByVal cbLen As Long)
Let's say someone tells you there's a RECT structure lying around at memory address 0x12345678, and if you don't make all its members zero immediately, your computer will explode.
Well, you know the destination (0x12345678) and the length (RECT is 16 bytes... Common knowledge :)), all you have to do now to keep your computer from exploding is to clear the RECT.
Code:
Call ZeroMemory(ByVal &H12345678, 16)
OK, that example was one of my worst, so ignore it, but if you like ZeroMemory then instead of doing this:
Code:
With MyRect
.Left = 0
.Top = 0
.Right = 0
.Bottom = 0
End With
You can do this:
Code:
Call ZeroMemory(MyRect, 16)
Another fun one is FillMemory.
Code:
Declare Sub FillMemory Lib "kernel32" Alias "RtlFillMemory" (pDest As Any, ByVal cbLen As Long, ByVal btFill As Byte)
Instead of this:
Code:
With MyRect
.Left = &HABABABAB
.Top = &HABABABAB
.Right = &HABABABAB
.Bottom = &HABABABAB
End With
Use this:
Code:
Call FillMemory(MyRect, 16, &HAB)
-
Oops... :rolleyes:
Sorry for that mistake.
P.S: Maybe cleaning memory leftovers is not the bes example.
Yonatan gave better examples.