the correct path is: HKEY_CLASSES_ROOT\Licenses\
not u201CHKEY_CLASSES_ROOT\Licenses\u201D
don't confuse with strings u201C and u201D because are ascii characters for double quotes (").
You can also use the path HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Licenses\ as stated in this link.
https://github.com/davidanger/MSCOMM32
(Courtesy noelbaez)
FUNCTION z_serial_comport.
"-------------------------------------------------------------------------------"
""""Local Interface:
"" IMPORTING
"" REFERENCE(MODE) TYPE I DEFAULT 0
"" REFERENCE(COMMPORT) TYPE I DEFAULT 1
"" REFERENCE(SETTINGS) TYPE C DEFAULT '2400,N,8,1'
"" REFERENCE(OUTPUT) TYPE C OPTIONAL
"" EXPORTING
"" REFERENCE(INPUT) TYPE C
"" EXCEPTIONS
"" NO_CREATE_OBJECT
"-------------------------------------------------------------------------------"
TYPE-POOLS: sabc.
INCLUDE ole2incl.
PERFORM init.
PERFORM open_port USING commport settings.
IF mode = 0.
PERFORM read_port
CHANGING input.
ENDIF.
IF mode = 1.
PERFORM write_port
USING output
CHANGING input.
ENDIF.
PERFORM final.
ENDFUNCTION.
DATA: o_obj TYPE ole2_object.
"-------------------------------------------------------------------------------"
FORM init.
DATA:
wa_repid LIKE sy-repid.
wa_repid = sy-repid.
CALL FUNCTION 'AUTHORITY_CHECK_OLE'
EXPORTING
program = wa_repid
activity = sabc_act_call
application = 'MSCOMMLIB.MSCOMM.1'
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT o_obj 'MSCOMMLib.MSComm.1'.
IF sy-subrc <> 0.
RAISE no_create_object.
ENDIF.
ENDFORM. " Init
"-------------------------------------------------------------------------------"
FORM open_port USING commport settings.
SET PROPERTY OF o_obj 'CommPort' = commport.
SET PROPERTY OF o_obj 'Settings' = settings.
SET PROPERTY OF o_obj 'InputLen' = 0.
SET PROPERTY OF o_obj 'PortOpen' = 1.
ENDFORM. "open_port
"-------------------------------------------------------------------------------"
FORM read_port
CHANGING input.
DATA:
wa_buffer TYPE i.
DO 10 TIMES.
GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
IF wa_buffer > 0.
GET PROPERTY OF o_obj 'Input' = input.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " read_port
"-------------------------------------------------------------------------------"
FORM write_port
USING output
CHANGING input.
DATA:
wa_buffer TYPE i.
SET PROPERTY OF o_obj 'Output' = output.
DO 10 TIMES.
GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
IF wa_buffer > 0.
GET PROPERTY OF o_obj 'Input' = input.
EXIT.
ENDIF.
ENDDO.
ENDFORM. "write_port
"-------------------------------------------------------------------------------"
FORM final.
SET PROPERTY OF o_obj 'PortOpen' = 0.
FREE OBJECT o_obj.
ENDFORM. " final
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 |