Failed in CreateFile to open COM Port

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I was adviced to create a new thread for this query and hoping to get it fixed.

My issue is this:
I can successfully open the communication port through directly using the port name in <span style="font-weight:bold lpFileName argument like the following:

<div style="text-align:left exp_powermonitor_connection.exppm_com = CreateFile(
                                                        TEXT("COM1")
                                                        ,GENERIC_READ | GENERIC_WRITE
                                                        ,0                       
                                                        ,NULL                   
                                                        ,OPEN_ALWAYS           
                                                        ,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED   
                                                        ,NULL);   


but the Port Settings should come from my INI File so I need to use a variable name for that argument, unfortunately it failed.
the return error by <span style="font-weight:bold GetLastError() is <span style="font-weight:bold ERROR_PATH_NOT_FOUND<span style="font-weight:bold

I print out the value of the variable name before calling the CreateFile() and i got the exact port name from my INI File.

how can I resolved this?

Thanks for any help in advance.


<span style="font-weight:bold

View the full article
 
Back
Top