From: Karl E. Peterson on
Norm has brought this to us :
> Karl E. Peterson formulated on Monday :
>> Norm pretended :
>>> Norm explained :
>>>> Larry Serflaten wrote on 5/23/2010 :
>>>>> "Norm" <NormF4(a)Spoof.com> wrote
>>>>>
>>>>>> There is apparently something going on here that I do not understand.
>>>>>
>>>>> It sounds like your program is getting called for each item in the
>>>>> list. Pass in 3 or 4 and see how many instances of your program
>>>>> get fired up....
>>>>>
>>>>> LFS
>>>>
>>>> Yes it is calling the program for each entry into the command line. I
>>>> have not been able to figure out what is being used to split the entries.
>>>>
>>>> Norm
>>>
>>> Larry, Jim,
>>> Your right in that I am having trouble understanding what is going on,
>>> partly I think in that I don't seem to be able to handle the messages
>>> being sent at the right time and partly in that I am making it harder than
>>> it should be. I was writing the Command$ to the registry and then reading
>>> it in a timer routine, if the routine got an entry from the registry it
>>> would then pass it to the cleaning routine, clean the file and then delete
>>> the registry entry. The problem was the second message sent to the next
>>> instance came so quick that it just wrote over the first registry entry so
>>> I only got one entry and one file cleaned. I like the chasing my tail
>>> analogy, as that is what I seem to be doing. ^^
>>>
>>> I found an example of Ken Halters that uses an ocx to do this same thing
>>> and will try and see if I can make it work.
>>
>> So what's with all the writing to the registry stuff? Is there a problem
>> with using one process per file?
>
> Larry,
>
> Either I don't understand, which is very possible, or I wasn't clear in what
> I am doing also very possible, as I get confused easily. ^^

Well, for starters, I'm not Larry. But I can overlook that. <g>

> My app is running all the time and subclassed with an icon in the system
> tray. When it starts it writes the registry entries to add a explorer context
> menu to secure clean files. I wanted to show baloon tips over the icon of the
> running program so if the program exe was started with a command line I did
> not know how to pass that command line directly to the present program that
> was running so I had it write the command line to the registry, then shut
> down the second instance and then the running program read the registry and
> executed the file cleaning. This worked great until I tried to do more than
> one file, then I had the problem since windows sends each entry through the
> context menu in a separate instance of the program.
>
> Searching Google I found a lot of question about this way back to 1997 and a
> lot of them answered by you. ^^ But no one seemed to have a solution that I
> was able to find, other than using DDE and I don't believe I can use that as
> I am not assigning specific files to my program, but want to clean any file.

I don't see any glaring reason you can't use DDE for this. That said,
you could be right -- I haven't done much with "any file" handlers.

WM_COPYDATA is another approach you may be more comfortable with. Both
methods are discussed here:

http://vb.mvps.org/samples/PrevInst


From: Norm on
Karl E. Peterson formulated on Tuesday :
> Norm has brought this to us :
>> Karl E. Peterson formulated on Monday :
>>> Norm pretended :
>>>> Norm explained :
>>>>> Larry Serflaten wrote on 5/23/2010 :
>>>>>> "Norm" <NormF4(a)Spoof.com> wrote
>>>>>>
>>>>>>> There is apparently something going on here that I do not understand.
>>>>>>
>>>>>> It sounds like your program is getting called for each item in the
>>>>>> list. Pass in 3 or 4 and see how many instances of your program
>>>>>> get fired up....
>>>>>>
>>>>>> LFS
>>>>>
>>>>> Yes it is calling the program for each entry into the command line. I
>>>>> have not been able to figure out what is being used to split the
>>>>> entries.
>>>>>
>>>>> Norm
>>>>
>>>> Larry, Jim,
>>>> Your right in that I am having trouble understanding what is going on,
>>>> partly I think in that I don't seem to be able to handle the messages
>>>> being sent at the right time and partly in that I am making it harder
>>>> than it should be. I was writing the Command$ to the registry and then
>>>> reading it in a timer routine, if the routine got an entry from the
>>>> registry it would then pass it to the cleaning routine, clean the file
>>>> and then delete the registry entry. The problem was the second message
>>>> sent to the next instance came so quick that it just wrote over the first
>>>> registry entry so I only got one entry and one file cleaned. I like the
>>>> chasing my tail analogy, as that is what I seem to be doing. ^^
>>>>
>>>> I found an example of Ken Halters that uses an ocx to do this same thing
>>>> and will try and see if I can make it work.
>>>
>>> So what's with all the writing to the registry stuff? Is there a problem
>>> with using one process per file?
>>
>> Larry,
>>
>> Either I don't understand, which is very possible, or I wasn't clear in
>> what I am doing also very possible, as I get confused easily. ^^
>
> Well, for starters, I'm not Larry. But I can overlook that. <g>
>
>> My app is running all the time and subclassed with an icon in the system
>> tray. When it starts it writes the registry entries to add a explorer
>> context menu to secure clean files. I wanted to show baloon tips over the
>> icon of the running program so if the program exe was started with a
>> command line I did not know how to pass that command line directly to the
>> present program that was running so I had it write the command line to the
>> registry, then shut down the second instance and then the running program
>> read the registry and executed the file cleaning. This worked great until I
>> tried to do more than one file, then I had the problem since windows sends
>> each entry through the context menu in a separate instance of the program.
>>
>> Searching Google I found a lot of question about this way back to 1997 and
>> a lot of them answered by you. ^^ But no one seemed to have a solution that
>> I was able to find, other than using DDE and I don't believe I can use that
>> as I am not assigning specific files to my program, but want to clean any
>> file.
>
> I don't see any glaring reason you can't use DDE for this. That said, you
> could be right -- I haven't done much with "any file" handlers.
>
> WM_COPYDATA is another approach you may be more comfortable with. Both
> methods are discussed here:
>
> http://vb.mvps.org/samples/PrevInst

Karl,
Sorry I did not even notice the change between Larry and you answering
this post. I have it working now, but am sure it is not the best, nor
easiest way to do it.

I did run across that page about the previous instance and download the
example. However when I tried to run it I was missng a msghook32 or
something similar that I did not hunt for at the time. Now that I have
it working good enough for me, I will go back and revisit the PrevInst
example.

Thanks very much to everyone for all the information and guidance, I
would really be lost without it, as I am still very much new at this,
even though VB is old. :D

Norm


From: Karl E. Peterson on
Norm wrote on 5/25/2010 :
> Karl E. Peterson formulated on Tuesday :
>> Norm has brought this to us :
>>> Karl E. Peterson formulated on Monday :
>>>> Norm pretended :
>>>>> Norm explained :
>>>>>> Larry Serflaten wrote on 5/23/2010 :
>>>>>>> "Norm" <NormF4(a)Spoof.com> wrote
>>>>>>>
>>>>>>>> There is apparently something going on here that I do not understand.
>>>>>>>
>>>>>>> It sounds like your program is getting called for each item in the
>>>>>>> list. Pass in 3 or 4 and see how many instances of your program
>>>>>>> get fired up....
>>>>>>>
>>>>>>> LFS
>>>>>>
>>>>>> Yes it is calling the program for each entry into the command line. I
>>>>>> have not been able to figure out what is being used to split the
>>>>>> entries.
>>>>>>
>>>>>> Norm
>>>>>
>>>>> Larry, Jim,
>>>>> Your right in that I am having trouble understanding what is going on,
>>>>> partly I think in that I don't seem to be able to handle the messages
>>>>> being sent at the right time and partly in that I am making it harder
>>>>> than it should be. I was writing the Command$ to the registry and then
>>>>> reading it in a timer routine, if the routine got an entry from the
>>>>> registry it would then pass it to the cleaning routine, clean the file
>>>>> and then delete the registry entry. The problem was the second message
>>>>> sent to the next instance came so quick that it just wrote over the
>>>>> first registry entry so I only got one entry and one file cleaned. I
>>>>> like the chasing my tail analogy, as that is what I seem to be doing. ^^
>>>>>
>>>>> I found an example of Ken Halters that uses an ocx to do this same thing
>>>>> and will try and see if I can make it work.
>>>>
>>>> So what's with all the writing to the registry stuff? Is there a problem
>>>> with using one process per file?
>>>
>>> Larry,
>>>
>>> Either I don't understand, which is very possible, or I wasn't clear in
>>> what I am doing also very possible, as I get confused easily. ^^
>>
>> Well, for starters, I'm not Larry. But I can overlook that. <g>
>>
>>> My app is running all the time and subclassed with an icon in the system
>>> tray. When it starts it writes the registry entries to add a explorer
>>> context menu to secure clean files. I wanted to show baloon tips over the
>>> icon of the running program so if the program exe was started with a
>>> command line I did not know how to pass that command line directly to the
>>> present program that was running so I had it write the command line to the
>>> registry, then shut down the second instance and then the running program
>>> read the registry and executed the file cleaning. This worked great until
>>> I tried to do more than one file, then I had the problem since windows
>>> sends each entry through the context menu in a separate instance of the
>>> program.
>>>
>>> Searching Google I found a lot of question about this way back to 1997 and
>>> a lot of them answered by you. ^^ But no one seemed to have a solution
>>> that I was able to find, other than using DDE and I don't believe I can
>>> use that as I am not assigning specific files to my program, but want to
>>> clean any file.
>>
>> I don't see any glaring reason you can't use DDE for this. That said, you
>> could be right -- I haven't done much with "any file" handlers.
>>
>> WM_COPYDATA is another approach you may be more comfortable with. Both
>> methods are discussed here:
>>
>> http://vb.mvps.org/samples/PrevInst
>
> Karl,
> Sorry I did not even notice the change between Larry and you answering this
> post. I have it working now, but am sure it is not the best, nor easiest way
> to do it.
>
> I did run across that page about the previous instance and download the
> example. However when I tried to run it I was missng a msghook32 or something
> similar that I did not hunt for at the time. Now that I have it working good
> enough for me, I will go back and revisit the PrevInst example.
>
> Thanks very much to everyone for all the information and guidance, I would
> really be lost without it, as I am still very much new at this, even though
> VB is old. :D

Yeah, MsgHook is just an ancient OCX that allows rather painless
subclassing. It was great for providing examples. (You can still
download it from my site too, btw - http://vb.mvps.org/tools/MsgHook)
I really only use native subclassing in production, though.
(http://vb.mvps.org/samples/HookXP) Glad you got it going!