|
-
Sep 24th, 2009, 02:05 PM
#1
Thread Starter
Member
[RESOLVED] Unable to delete Atom with GlobalDeleteAtom
I have created the atom and I know how to get the name of the atom, but I can't for some reason delete the atom that I created.
atomName = "KeyPress"
atomAvail = GlobalFindAtom(atomName)
(atomAvail should be a 0 to let me know that the Atom is available, but this only worked the first time and now always has the integer value assigned to it regardless of GlobalDeleteAtom call)
atomNum = GlobalAddAtom(atomName)
GlobalDeleteAtom (atomNum)
end function
What am I doing wrong?
-
Sep 24th, 2009, 03:20 PM
#2
Re: Unable to delete Atom with GlobalDeleteAtom
Here is some comments from MSDN
 Originally Posted by MSDN
The string associated with the atom is not deleted from memory until its reference count is zero. For more information, see the GlobalDeleteAtom function.
Global atoms are not deleted automatically when the application terminates. For every call to the GlobalAddAtom function, there must be a corresponding call to the GlobalDeleteAtom function.
Reading the above, you may not have all instances deleted.
-
Sep 24th, 2009, 03:34 PM
#3
Thread Starter
Member
Re: Unable to delete Atom with GlobalDeleteAtom
Thank you for the information. I am teaching myself API and I know I am not going to master it in a couple of days.
Do you know if there is a way to determine the number of instances of the Atom exist? Should I just write an ad hoc procedure to GlobalDeleteAtom to loop until GlobalFindAtom = 0?
-
Sep 24th, 2009, 03:41 PM
#4
Thread Starter
Member
Re: Unable to delete Atom with GlobalDeleteAtom
I just tried my idea of using a loop to make sure that there are no instances of the atom I created and it worked and you were right as to the cause of my problem and helped guide me to a solution. Thanks again and for those that see this and may be an API newbie, this is what I did...
(In VB)
Do Until GlobalFindAtom = 0
GlobalDeleteAtom(***whatever your atom number variable is here*****)
Loop
-
Sep 24th, 2009, 05:46 PM
#5
Re: Unable to delete Atom with GlobalDeleteAtom
 Originally Posted by osulliga
Thank you for the information. I am teaching myself API and I know I am not going to master it in a couple of days.
Do you know if there is a way to determine the number of instances of the Atom exist? Should I just write an ad hoc procedure to GlobalDeleteAtom to loop until GlobalFindAtom = 0? 
Glad you resolved your problem. But to answer the above question, not off the top of my head. Per MSDN documentation, when you delete the atom, the return value is always zero which doesn't help much. Some APIs will return a value of how many instances are left, and in other cases, there may be APIs created just for that purpose. I have been using APIs for decades, but I am not fluent with the GlobalAtom APIs.
-
Sep 24th, 2009, 06:24 PM
#6
Thread Starter
Member
Re: [RESOLVED] Unable to delete Atom with GlobalDeleteAtom
Do you know of some good resources I can read up on for API? Most of the coding books that I have either pertain to VB, C#, .Net, SQL, etc.
Thanks again.
-
Sep 24th, 2009, 06:38 PM
#7
Re: [RESOLVED] Unable to delete Atom with GlobalDeleteAtom
Honestly, no. APIs have 2 challenges: 1) Knowing they exist and 2) knowing how to use them.
Here are a couple of sites that can help
1. The API List at allapi.net. Bookmark it. Has a majority of the most common/widely-used APIs with examples and documentation how to use them. Also has the API Guide download which is basically a database and app that contains all the APIs you will see on that site.
2. The API Viewer. A must for programmers. Contains all the API declarations in item 1 above and more. Contains 1000's of constants.
3. Forums like this one
4. The ultimate guide for all Microsoft APIs: MSDN.com, but documentation is not in VB-lingo so it takes some getting used to. Enter API or constant in its search engine.
5. Google. Entering the API name along with "visual basic" should find you several more usage examples of whatever API you are looking for.
Example Google search for DeleteAtom: DeleteAtom API "Visual Basic"
Example Google search for constant WM_APP: Const WM_APP
The above search formats will return more VB examples than non-VB examples
6. One of my favorite bookmarks: http://vbnet.mvps.org/index.html
Last edited by LaVolpe; Sep 24th, 2009 at 06:46 PM.
-
Sep 30th, 2009, 11:26 AM
#8
Thread Starter
Member
Re: [RESOLVED] Unable to delete Atom with GlobalDeleteAtom
Thanks for the info, I do have the API Viewer and API guide applications, and have been very fond of this website and google.
The one site that I haven't used is one you had listed as your favorite. I now have added that to my bookmarks for quicker reference.
Thanks again.
-
Sep 30th, 2009, 01:02 PM
#9
Re: [RESOLVED] Unable to delete Atom with GlobalDeleteAtom
Well if you like that bookmark, here is another that I use almost exclusively for GDI+ APIs. That site has much more than GDI+.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|