×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-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!

*Tek-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

Win API calls work in Visual Basic 6 IDE but not in EXE file

Win API calls work in Visual Basic 6 IDE but not in EXE file

Win API calls work in Visual Basic 6 IDE but not in EXE file

(OP)
I have a program written in Visual Basic 6.  It uses Win API calls for serial port communication using CreateFile, WriteFile, ReadFile, etc calls from the Win API.  It works fine when in the IDE.  When I make an EXE file and run it, the program crashes.  The WriteFile and ReadFile calls seem to be the problem.  Can anyone give me a possible reason for this?
Thanks.

RE: Win API calls work in Visual Basic 6 IDE but not in EXE file

Add return codes handling in your code, print proper diagnostic messages. Check file names in you code - have you full or relative only paths to processed files?

RE: Win API calls work in Visual Basic 6 IDE but not in EXE file

Since the progam seems to crash, I don't think a return code will be possible to obtain.

Crashing usually means memory/stack corruption. You may want to check the parameters to these funtions. Are these of the correct type and size? Are you maybe specifying an empty stringbuffer to readfile, etc. etc.

Greetings,  
Rick

RE: Win API calls work in Visual Basic 6 IDE but not in EXE file

(OP)
Thanks for your help.  I found the problem.  I was passing a variable as byVal when it should been byRef instead.
Al

RE: Win API calls work in Visual Basic 6 IDE but not in EXE file

Yup.  Passing a string to a Win32 API function will do that to you every time, if you don't use ByRef.

Chip H.

____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first

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 Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

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

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close