Results 1 to 8 of 8

Thread: Forking / New Process in VB .dll ??? Please help :(

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    45

    Angry Forking / New Process in VB .dll ??? Please help :(

    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-

  2. #2
    jim mcnamara
    Guest
    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.

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    45

    Angry

    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 ....


    Code:
    Dim objMail as SE.Email
    
    Set objMail = New SE.Email
    objMail.SendEmail "Test Email", "[email protected]", _
                              "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-

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  5. #5
    jim mcnamara
    Guest
    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.
    Code:
    'in YOUR  activeX
    Shell "MymailServer.exe -t:[email protected] -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.

  6. #6

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    45

    Thumbs up

    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-

  7. #7
    jim mcnamara
    Guest
    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.

  8. #8

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    45
    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-

Posting Permissions

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



Click Here to Expand Forum to Full Width