×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

API for detecting SW application launch...

API for detecting SW application launch...

API for detecting SW application launch...

(OP)
I have program (in VB6) that runs as a standalone application but also has the ability to connect to SolidWorks and provide a certain level of integration as well.  Users may or may not need to use the application in conjunction with SolidWorks at any given time.  I'm in the process of expanding functionality and making it more bullet-proof.  I already have the ability to create or connect to any existing SolidWorks object.  One thing that I'd like to be able to do, is to have functionality that sits waiting to detect the launch of SolidWorks in Windows (if it isn't currently running) which will fire off a series of events in my program that will attach to the SolidWorks object.

I obviously wasn't paying attention very well the day they taught us that in school.  But as I recall this doesn't pose very much of a programming problem.  For the life of me I can't seem to track down anything decent in the way of information on detecting Windows Events (which I believe an application launch falls under).

Sorry if this is a bone-headed question but any help or suggestions would be greatly appreciated (pointers to info or code samples especially).

Thanks,
Chris Gervais
Mechanical Designer
American Superconductor

RE: API for detecting SW application launch...

Target location: Executables under the SolidWorks Icon on the desktop
"J:\ SolidWorks\Executables\StartSolidWorks.exe"

Then in the VB program J:\ SolidWorks\Executables\StartSolidWorks.exe have the following:

Private Sub Form_Load()
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
lPid = Shell("J:\ Executables\CopyFile.exe", vbNormalFocus)
If lPid <> 0 Then
    lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)       ' Get a handle to the shelled process.
    If lHnd <> 0 Then                              ' If successful, wait for the
        lRet = WaitForSingleObject(lHnd, INFINITE) ' application to end.
        CloseHandle (lHnd)                         ' Close the handle.
    End If
End If
Dim StartSolidWorks As String
Run Copy Files program & SolidWorks.
       StartSolidWorks = Shell("C:\Program Files\SolidWorks\sldworks.exe", 1)   ' Run Copy Files program & SolidWorks.
Call cmdExit_Click
End Sub


Bradley

RE: API for detecting SW application launch...

(OP)
Bradley,

Thank you very much, this looks pretty good and I believe I understand the general gist of how the code works though I'll need to read up on some of the functions your using to understand fully.  But I'm unclear on what CopyFile.exe is and what it is/does.  If you would, please walk me through what the purpose of this exe is and how it fits into the code.

Thanks Again,
ChrisG

RE: API for detecting SW application launch...

ChrisG,
The functions in StartSolidWorks.exe I do not understand at all.  I copied it off some website.
The CopyFiles.exe program copies the macros you have written for SolidWorks, each time a user double clicks the SolidWorks icon.  This way, you update all macros to each person’s hard drive. I have removed all the extras from my program to make it easier to understand.  Build the following program in VB and save it as J:\ Executables\CopyFile.exe

Private Sub Form_Load()
FileCopy "J:\ SolidWorks\Executables\bomtemp.xls", _
         "C:\Program Files\SolidWorks\lang\english\bomtemp.xls" '   To:
'   Ctrl F12 - Title Block program
FileCopy "J:\ SolidWorks\Executables\TitleBlock.swb", _
         "C:\Program Files\SolidWorks\Macros\TitleBlock.swb"    '   To:
    Unload Me
    End
End Sub
* * * * * * * *
This is easy and invisible to users.  Once you get the SolidWorks Icon setup, you or the user may not need to touch their machine again.  The user will have to program the macro keys, for e.g. Ctrl F12 for TitleBlock.swb macro.
If you have anymore questions please ask.

Bradley

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources