Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

AlanMiller

Programmer
Feb 18, 2005
2
US
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.
 
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?
 
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
 
Thanks for your help. I found the problem. I was passing a variable as byVal when it should been byRef instead.
Al
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top