General discussion

Locked

Linking VB and C

By shajithchandran ·
What is the best way to link C and VB. I know that it can be done using the command shell. But I face some problem with that. My problem is that until the exe file is excuted i cannot proceed to the next statement in vb code. I want make sure that before the next statement is executed (in the VB code) the exe file is completely run. I did it by putting a loop between the statements but again this depends on the system speed and load. It can fail sometimes.Please suggest me a solution to this.

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Linking VB and C

by JackOfAllTech In reply to Linking VB and C

Are you trying to run another program from within a VB program? Is the other program cmdline-only or is it a Windows program?

There are many VB specific sites on the 'net. I have seen several articles on how to wait for another program to finish before continuing the current one. Do a little research.

Ralph

Collapse -

Linking VB and C

by shajithchandran In reply to Linking VB and C

Poster rated this answer

Collapse -

Linking VB and C

by shajithchandran In reply to Linking VB and C

Point value changed by question poster.

Collapse -

Linking VB and C

by ram_cv In reply to Linking VB and C

There could be quite a few methods to achieve this goal:

1) In your C program create a predefined file at a predefined directory. This file should be created when the C program exits. In the VB program check for this file's existence in a loop and proceed further only when the file is created.

2) Use Windows messages. In your C program when you are finished and are going to end, send a Windows message to the VB program. The VB program should be doing a doEvents and waiting for this event.As soon as it recieves this event it should go ahead with its processing.

Also there are other methods of IPC like sockets which can be used for this purpose, but one the above two should be the most suitable for your purposes.

Cheers!
Ram

Collapse -

Linking VB and C

by shajithchandran In reply to Linking VB and C

Can u please explain the second point in brief. I looking for something like fork/exec-wait.

Collapse -

Linking VB and C

by ram_cv In reply to Linking VB and C

In VC register a windows message, I think there is an API call called RegisterMessage. Then subclass your VB application to listen for that Message. Then do a PostMessage from VC to post that message for the VB application to wakeup.

Collapse -

by Sygnosys In reply to Linking VB and C

The best way to link C and VB, in my opinion, is through a DLL. Just pick up your C code and build a DLL from it!
But if you want to stick with an independent exe
you can use the shell function and simply state in the 3rd parameter true and this will make shell function sync with the execution of your exe.

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums