News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Hotkey code and text 2 clipboard merge

Started by Magnum, December 15, 2010, 12:41:51 AM

Previous topic - Next topic

Magnum

If you are interested, I have some code that is leak free.

Don't know how fast it is though.




Have a great day,
                         Andy

dedndave

thanks Andy
speed isn't really a critical issue because the API functions are slow as hell, anyways
but it is interesting to note the speed - maybe it's telling us if something is wrong
with some code sequences, i get a time around 33,500 cycles and with others i get a time around 23,500
i think using the right sequence and properly handling errors are important
also, returning a status code, as opposed to displaying an error string, will make the routine usable in native, GUI and console mode programs

Magnum

Good luck in your project.

Since my program uses the clipboard to store the text for the Keyboard shortcut keys ,
a second program using a different key combination overwrites the first.

And then there is the issue of my programs taking up some "real estate".

Hopeful I can find some way to store the text somewhere else.

I am happy that I have learned a lot of new material.



Have a great day,
                         Andy

dedndave

well - i have a routine that passes all my tests - lol
let's see if it passes everyone else's.....

Magnum

Have a great day,
                         Andy

dedndave

thanks Andy   :U

i have checked it with RuntimeChecker
no matter how many times it is called, it leaves 1 Global handle opened
i suspect that is proper behaviour - the OS closes the others as it discards them
i am going to write a little "wrapper" function that adds the code tags   :P

Magnum

What do you mean a wrapper with code tags?

I have several variants of code that send text to the CB.

One of the versions had no "leaked blocks."

Some advice that someone gave me concerning finding the leak.

< And it should be telling you something about where the block was
< allocated., including, if symbols are available, a good chunk of the
< call stack leading to the allocation.

Have a great day,
                         Andy

dedndave

the last version is leak-free, Andy   :P

what i meant by code tags...
are the [ code ] and [ /code ] tags for pasting text into the forum
i have a little routine that adds them to the paste text, then calls the SetCbTxt function

...although, it might be better to write it as a self-contained modified version

MichaelW

Dave,

Running your code under Windows 2000 I cannot detect any significant difference in the memory usage with or without the GlobalFree, even with a much larger number of iterations and a much larger string (I added the "significant" qualifier because I occasionally see a 4KB difference in the numbers). Within the loop the first call to GlobalAlloc increases the memory usage, and with or without the GlobalFree subsequent calls to GlobalAlloc do not increase it further.
eschew obfuscation