Consulting

Results 1 to 3 of 3

Thread: Multiple Winword Process - Conundrum - how to find the PID?

  1. #1
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,478
    Location

    Multiple Winword Process - Conundrum - how to find the PID?

    I've run into a hard crash bug, and I'm not 100% sure how to fix. It's been a while, and I hope you're all well.

    A little background, although I'm sure I'm not telling the folks I hope to brainstorm with anything they don't know.

    Each time my addin loads, I mark down the memory location of the ribbon -- it's a LongPtr in 64-bit office... but bottom line, it's the memory location in RAM associated with the ribbon UI -- and it looks something like this: 123120947574012630. This is a common practice, and I know it's not unique to my programming.

    The problem is this: if a second winword process loads and writes down the memory location of the ribbon -- it overwrites the memory location of the first ribbon. And any attempt by the first winword process to reload the ribbon from the memory location causes a hard crash.

    The solution seems obvious - start marking down the memory location along with the PID of the winword process (or some other identifying thing about the application), so that Winword1 only reloads Ribbon1, and Winword2 only reloads Ribbon2. The crash comes when Winword1 tries to reload Ribbon2.

    But even though I can use some code to get the PID of the latest winword process when I write down the ribbon's memory location -- that still doesn't solve the problem of my code *knowing* which PID is running it.

    Any ideas?
    _______________________________________________
    Please don't cross-post without providing links to your cross-posts. We answer questions for free. Please don't waste the time of the people helping you.
    For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

    - Frosty

  2. #2
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,478
    Location
    Also, I'm perfectly happy to throw this entire solution out -- the main point is that I need to be able force a dynamic menu in xml to refresh at will -- even after I may have used "End" in the macro project (and thus, killed the global variable that held the ribbon in memory).

  3. #3
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,478
    Location
    Sometimes, you miss the forest for the trees.

    For posterity:
    Declare PtrSafe Function GetCurrentProcessId Lib "kernel32" () As Long

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •