PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

FreeResource() & UnlockResource()

Are FreeResource() and UnlockResource() supported in Windows CE? I've been trying to use them and I keep getting errors. Is there a header to include I'm missing? Thanks!

P.S. - An unrelated question: if I'm running something in the emaulator, is it possible to output values to the output window of eVC++? If so, how?
P.S. - An unrelated question: if I'm running something in the emaulator, is it possible to output values to the output window of eVC++? If so, how?


I found the function NKDbgPrintfW which seems to do that sort of thing (if you run using F5 instead of Clrt-F5).

I'd be interested to know how you are supposed to do this though...
There is no need for FreeResource. When the module containing the resource is loaded, the resource is loaded into a read-only page(s) of system memory. LoadResource returns a pointer to this area of read-only memory to all who ask for it. Since it's read-only the OS doesn't need to perform a copy on write so only one copy need be in memory at a time. The way you free this bit of memory is to unload the module.

Also disregard that blurb in the docs about using DeleteObject, DestroyCursor, etc. in order to free the resource. That's just wrong. In the case of bitmap resources, GDI only knows about handles to GDI objects and the LoadResource does not return a GDI handle. Passing in the value returned by LoadResource to DeleteObject will fail.

All those Lock/Unlock shenanigans are a hold over from Win16 where you would have to lock global memory before using it and then unlock afterwards so the memory manager could defragment the global heap.
Dave:

I just tried it using F5 on the emulator and it "worked" for me.

Include "dbgapi.h" in your C file and use the NKDbgPrintfW like a printf.

for(int i=0;i<4;i++)
NKDbgPrintfW(TEXT("HELLO!"));

Spewed:

HELLO!HELLO!HELLO!HELLO!

Into my debug window.
angedelamort · 20 Jun 2002, 13:34 UTC
For my part, I'm using OutputDebugString.

here a paste from the msdn help

OutputDebugString
The OutputDebugString function sends a string to the debugger for the current application.

VOID OutputDebugString(
LPCTSTR lpOutputString // pointer to string to be displayed
);

Parameters
lpOutputString
Pointer to the null-terminated string to be displayed.
Return Values
This function does not return a value.

Remarks
If the application has no debugger, the system debugger displays the string. If the application has no debugger and the system debugger is not active, OutputDebugString does nothing.

fzammetti · 20 Jun 2002, 14:33 UTC — Thanks!
Thanks guys, those work great, not sure why I didn't find them before when I searched the documentation. Ah well, there's lots to search through, missing something isn't unusual.

Too bad this seems to only be possile while in debug mode, it'd be nice if I could do this from just an executing application, but it makes sense that you can't do that since there is no connection to the IDE in that case.