Make sure the icon is 32 x 32 and 16 colors. Also, identify your constants so you know what flags you are applying. Very helpful for when you look at your code in the future and wonder what the heck you were doing in the past.
And why after all the talk about LoadImage have you decided to use LoadIcon ? LoadIcon loads directly from a module (app, exe) so it needs the hinstance of the module.
try:
rem change darkbasic window icon
rem latch
rem 04/08/2009
set window on
user32=1
load dll "user32.dll",user32
hwnd=call dll(user32,"GetActiveWindow")
IMAGE_ICON = 1
rem assuming this is a legit sized icon and valid path
fname$="C:\Documents and Settings\Caleb\My Documents\My Projects\ZombieVille\Icon.ico"
LR_LOADFROMFILE = 16
LR_DEFAULTSIZE = 64
cx=0
cy=0
fuload=LR_LOADFROMFILE | LR_DEFAULTSIZE
iconhnd=call dll(user32,"LoadImageA",0,fname$,IMAGE_ICON,cx,cy,fuload)
rem should be non zero for verification of retireving the handle
print iconhnd
GCL_HICON = (-14)
oldicon=call dll(user32,"SetClassLongA",hwnd,GCL_HICON,iconhnd)
Enjoy your day.