/* ** hIcon = some icon.... ** hIcon = ohyeah(hIcon); ** hIcon = ohyeah(hIcon); ** hIcon = ohyeah(hIcon); ** ... */ HICON ohyeah(HICON hIcon, int value) { static HICON dupicon; static BOOL firstrun = 1; //dupicon = DuplicateIcon(NULL, hIcon); dupicon = CopyIcon(hIcon); //showerror(GetLastError(),0,0); if(!firstrun) { DestroyIcon(hIcon); printf("DestroyIcon\n"); } hIcon = dupicon; printf("dupicon = %p\n",dupicon); firstrun = 0; return dupicon; } /* If I comment out DestroyIcon() I get a new address every time ** with the DestroyIcon() I get 0 as a result the second time it's called */