Click to See Complete Forum and Search --> : Forking / New Process in VB .dll ??? Please help :(
Pure Krome
Apr 2nd, 2002, 11:51 PM
Hello Guru's.
I've got some .dll i use for my ASP site. It's all working perfectly, etc etc etc etc.
Now, there's a bit of code in there that emails someone, something. It's a 3rd party product, which we -have- to use. Please, just try me on this.
Now, i was hoping to have my code FORK OFF a new Process, which does the 3rd party email, etc....
Is there any chance i could have this happen? This way, in -MY- code, when i hit the email bit, i fork off the email (which can happen as slow as it wants to), but my code keeps on working normally, not waiting OR CARING about the process at all. If the forked off process fails, or something bad goes wrong .. i don't care. i'll do some other handling in there.
Please tell me this can be done. I'm using Visual Basic to make the .dll also.
Thank you kindly to any help forthcoming.
-Pure Krome-
jim mcnamara
Apr 3rd, 2002, 09:05 AM
If you really want to fork, just call _exec() in VC++ or
call the CreateProcess api from Visual Basic.
You can also get a return status, just like unix.
Download the www.allapi.net api guide (free) - it has good examples of CreateProcess.
Pure Krome
Apr 4th, 2002, 01:35 AM
Hi Guys ....
hmm .. interesting..
<spends all day trying some things, including reading those two links>
Ok .. lets see .. the basic gist of those helpful links, etc basically say i need to make an ActiveX EXE, and then asyncy process that.
Sweet.
<makes the activex exe>
<tests the activex exe>
:) Perfect. Ok. I've done the ActiveX exe, but it's not being called ASYNCRONOUSLY.
I've read the msdn, and also the API downloaded file. I like the downloaded API file example the best, but it still doesn't help with my problem.
This is the code i have on the CLIENT ....
Dim objMail as SE.Email
Set objMail = New SE.Email
objMail.SendEmail "Test Email", "billy@microsoft.com", _
"From Some Sender", strCompanyEmailAddress, strMailMessageBody
So could someone explain to my single cell brain what I would need to do to call this ASYNCRONOUSLY please?
*beg*
-PK-
Edneeis
Apr 4th, 2002, 10:43 AM
Well I hate to be on of those selfpromoting guys, BUT download the AsynchTasks sample from my website and Put any code that sends the email in the TimerProc sub of the AsynchProcess component then just call it from your exe. If you didn't compile the activeX exe then you'll need to register or run it first before using it.
jim mcnamara
Apr 4th, 2002, 10:48 AM
What you want is the "T" word - thread. But you cannot thread using VB. It doesn't work - a known bug.
Methods called in VB complete synchronously by default.
The only way you can get this to work is to have a separate entity (read exe file) that you shell to from your ActiveX component.
'in YOUR activeX
Shell "MymailServer.exe -t:Johhn@microsoft.com -f:myfile.txt"
MyMailServer.exe references the third party dll, your code does not.
MymailServer lives in it own process space. It ends after the mail is sent. It goes off and does it's thing, your code does not wait for it. Forking in other words.
This is what you suggested - I cannot see how it is NOT possible to do this.
Pure Krome
Apr 4th, 2002, 06:01 PM
Hmm..
I was hoping to AVOID using the SHELL to execute my .exe.
wy? i didn't not want to pass anything into the .exe via command line args.
What i will do now is (unfortunatly) pass in a SINGLE command line argument as some XML. Why XML? becuase i think it would get very messy trying to parse the command line args, when one of the args will be an email message, which could be very long, etc.
If i encapsulate all the input text into one xml string, then i can easily parse ;)
Ok. thanks heaps for all the help. Most appreciated :)
-PK-
jim mcnamara
Apr 5th, 2002, 09:10 AM
Look into CreateProcess api call. You do not create a 'command' line for it. It's simply a parameter string placed in a struct in memory. I mentioned Shell because it's the poor man's way of doing this.
Pure Krome
Apr 8th, 2002, 07:27 PM
Hi Guys...
with lots of trial and errors (is that always the case), i've ended up using Edneeis code example. Though it is a bit more complex / cumbersome that i thought, it does work, and that is all that matters to me right now.
I would have loved to seen an example of CreateProcess which passes a score of params, but not COMMAND-LINE like ... and where these params COULD be either floats, integers AND STRINGS (strings == paragraphs of text .. not a single word).
-PK-
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.