15
!"# $ % & () *+,- ./0 &(1 & $ 2 34567859:; [email protected] % ! "# $%# & # $ ( ! ) * %# +,-./0$1"# 22( 3 4 5 4 16 ( ! 575 7 1" * 7 *7(89:9--,-8;:<16 * ! =)5 >7#& $%#45 ?"16 * @ ! ( !5*)8,:A;B9-C;D.E<,: 1 *75 *73 # ( !)( !5*"#516)55 ( !)5(F !5’ ( !)( !58C 1* % ! $) 16 ! #5 & # 5%# G *%" * ( !5* 16)1H 7 1"F5( 7 1"! $1"3 #*716) ( ! ) 5 ! 16)’ 7# 0B.E< ())5;E<.E< # ! !(I16 5 7 1" ! ( ! ") 57# & * 7 ) 4 @ 75 *7=&’ %7F 431J KKLMMN3# @ ! ) OPPPLQRN3 @ 4 $%# %% 5 75 * 7 $# S %( LK C;D.9<0T0-0<UD;V, QKW0TT-,D;V, XKYU<,D;V, NKP88D;V, SK PC8D;V, ") % 1 # ( ! Z88 [ P88"PC8 ) S %7# 5#%%Z88Z<9BV9:V 89:9--,-8;:< 5 3%\;D.9<0T0-0<U [B0TT-,"TU<,D;V,)PC8 >P884 ! 5 3 ( ! 575 I 3 5 ") I 5 5 75%Z88%# 4 F 5 ) ?) ( ! 3 # 1 * ) ) 5H) 5 * 7 H& # " ) 3 # %PC8( P8816 45 4 I3 5 4&5) % @ 1 L]Q^Y) " = 5 % ! 7 1" )57#& 5 ) 5% %_PC84’ 5 "+^‘+0:,\<^,D;:U‘\\,AA "aOaba0:A<0Bc0:A<;E< YEcc,:’ 3# 5 $)#5H) 74 7# & H) C8d( 3%( ! ?

0˙&(1& ˇ$2 3 45 67 8 59:; - ett.co.th · ˘ ˇˆˆ˙˝ ˛˚ ˜ !˝" # $ˆ˙%< 3 ˚ ˚ interface

  • Upload
    builien

  • View
    223

  • Download
    0

Embed Size (px)

Citation preview

������������ ������������������������������������������ !�"�#�

�$�����%�

�&'()���*+,-�./0�&�(1&�

�$�2�3�45�67�8�59:;��

������������ ��[email protected]������������������������������������������

��

%���������

������� ���!"�#��$%#&# �����$����'�����(! ��) � *� ����%#���+,-./0����$1"�#������22�( ������3���45��4 ��16��(! 57 5��7����1"������ *�7���

� *�7���( � 89:9--,-�8;:<��16�� *���!��=�)5>��7# �&�$%#��45�����?����"���16�� *���@���!������(! 5� ������ *�)�������� �8,:A;B9-� C;D.E<,:�� 1�����*7 5� *�7��� � �3�#�'�����(! ��) �����(! 5����*"�#����5�16��) 5�5��(! ��) ���5��( ���F!5�'������(! ��) ��(! 5�8C� ��� �1��*��� ���%���!$�) '�16���! ��# 5�����&#�5%#�G*%"�*���������� �����(! 5� ������ *�16��)��1����H����7����1"�� F5���( ������7����1"����!�$1�"��3�#� *�7���16��)����(! ��) ����5 ��!�16��)���'�7#��0B.E<���( �)���)5 ���;E<.E<����#��!��!���( �I�16�����5��7����1"�����!�������(! �'���"���)57# �&����� *�7����)��4��

��@�7 5� *�7��=&��'��%7F4�3�1J��K�K�LMMN���3�#��@���!��������)�OPPP�LQRN�3���@���4$%#�'��%���%��'5�7 5� *�7��� $�#�S����%��( �

� LK�C;D.9<0T0-0<U�D;V,�� QK�W0TT-,�D;V,�� XK�YU<,�D;V,�� NK�P88�D;V,�� SK�PC8�D;V,�"�)�%�1���� ���#��������(! �Z88[�P88�"���PC8�����)�S����%7#5�#���%����%�Z88��Z<9BV9:V�

89:9--,-�8;:<�� �� �������'5�3����%�\;D.9<0T0-0<U[�B0TT-,�"���TU<,�D;V,��)���PC8>P88���4� ����!�������'5�3��(! 57 5����I�3���'5��"�)�I��5����������'5�7 5���%�Z88�%#��������4� F5���) �?�)���(! 3�# �1��*�) �)�5H)��5� *�7���H&# �"���������)��3�#������%�PC8��( �P88��16��������45��4�������I�3���'5���4��&5��)���%��@���1����L]Q� Y� �) �������"����=�� � ���'5� ���������%���!��7����1"���)57# �&�����5 �)5�%�����%��_��� PC8� ��4� ��'5�"���+^ ��+0:,\<� ,D;:U� \\,AA��"���aOab��a0:A<�0B�c0:A<�;E<��YEcc,:��'3�#��'5�$�)�# 5H)�7�4�� ��� �7# �&�H)��C8d����( �3����% (!�?��

������������ ������������������������������������������ !�"�#�

�$�����<�

%�5��4��=#��( �3�#���%7 5� PC8� ��7����1"���I ���%��7F4����$�)�# 5�7����1"���� � ����H�%��%%#����� 5�"=���5�'5�$%#�I� ��%#����%���5�5����7#���$%#������%��'5� (!�? ��%#��� F5�16�����H���!H&#�7����1"��"��H&# �"��G*%"�*������! ���( �3�#���%��4��!�� 5�

���2.(=�� ��'"���'7 5ef��gh+�7 5�Pii��'3�#H�$%#���)��(! 5�8C���4�&1"����'5�7 5� *���!"���)5�����(! 5�)���)?���45��4�����@� �������5��!�� 5�%#��������4���� �)57 5�1"��3������ ���1j2������(! 5�)���)�"�)��)��!%& ��=���7 5���1���������!�k0BV;lA� m8� "n5�k0BV;lA�MR��) ��16����� �$%#�)1j ������(! 5�)���)�) ��� �&)�# ���)��(! 5�)�3��)?���!��=�'5�$%#����k0BV;lA�m8�$%#�16� �)5%��%�5��4���������4 F5��)5��#����G*%"�*�)��3�2)7 5��%�)���������

<��(��*�1��&'(��� �'"��)5� *���8;:<�9VV:,AA��7 5� *�7��3���(! 5� ������ *��!3�#��4��'��%� $�#�Q�� *��( �o8iL�"���o8iQ� ���=7��$%#�N�� *���( �16��o8iX�"���o8iN��nF!51���"�#� ��'��%�'"��)5� *�� $�#��!�XpRLq�"���QpRLq�%�5�5��!�L�"�)=#�# 5� )��)�'"��)5� *���=�'$%#�%�� )�7# �&� ���)����� '����'"��)5��!���� $�#3��5��!Q������ ��% )�$%# �� �>�?�675�@;���4@A��9A��9�:�����(����%��'"��)5� *�7 5�o8iL�"���o8iQ�

�������� ������ ������������ �� �� ������������������� ����� !"��#$����#���� %&'��(#$���(#���� %&'(�

�(����<��'"��)57 5��)����� '��!��I��)�'"��)5� *�7���

�������� ������ ))))*)+)$� �,����-�.,/��� 0�/�%&'��))))*)+)1� �,����-�.,/��� 0�/�%&'(�))))*)+)�� �,����-�.,/��� 0�/�%&'��))))*)+)2� �,����-�.,/��� 0�/�%&'+�

���2.(=�� 3��3�#5� �5�# 5�� � ��) ��)�)3��C bZ���4�$%#�'��%�'"��)57 5�o8iL�"���o8iQ�� $�#����'"��)53%���45��4��(! 5 ��H&#�7������)�W;<,�T;;r�7 5�0TD���!H&#�7���3�#��4��'"��)57 5� *� �"���)5����)��@��%�5��4��3���7����1"�� F5�# 5�1��!���)�'"��)53�#=&��# 5%#�����_���4���'5�7 5�1"�� �H�%��%$%#��� ��5��!�L� ����)H�$%#����)�o8iL�3�#�'"��)5�XpRLq]QpaLq�nF!5�������)3����!55� �5��4� �� 5�)�'"��)5�XpRLq���4��16��'"��)5@���Y9A,�9VV:,AA��"�� '3�#�'"��)5�Y9A,sL�����Y9A,sQ��'�����!55����!������nF!5��1��#��!$%#%�5�5��!�X��

������������ ������������������������������������������ !�"�#�

�$�����B�

(����B���#��!7 5� *���������� ������� ������������� ��3456)� ����07� 89�:;3<3)�#=��8����/�+�>�?@��A� B�7��C/�,�.-9?0��.��3456�� �����D�.?� B�7��C/�,�.-9?0��.��3456(� ��������� � B�7��C/�,�.-9?0��.�

B��)���CC�D��� 3�&1��!�L�"�%5� �%���577 5� *�7�����16����%�+Y]QS����H&#����!� �3�#�'�����(! ��) ����5 ��� ��nF!5��#��!7 5"�)��7��4��16�%�5�5��!�N��(����E���#��!7 577 5� *�7������ �������� ������ ������ ����� �

�� E"<FGH5� �GI<FGJ)� KL,�(� ;3<3)� ;3<3)� B ,��� ;3<3�� ;3<3�� B ,�+� ;3<3(� ;3<3(� B ,�M� ;3<3�� ;3<3�� B ,��� ;3<3+� ;3<3+� B ,�#� ;3<3M� ;3<3M� B ,�$� ;3<3�� ;3<3�� B ,�N� ;3<3#� ;3<3#� B ,��)� E1OP� "<3<Q4�� B ,���� �Q4R� "<3<Q4#� KL,��(� &3S5F�!Q<E2IT� "<3<Q4M� B ,���� "5J5O<� "<3<Q4+� B ,��+� E1Q<G�%UI5�V55T� �GI<FGJ�� KL,��M� E2FFGF� "<3<Q4�� B ,���� E IU<U3JUW5� �GI<FGJ(� B ,��#� E"5J5O<�&FUI<5F� �GI<FGJ�� KL,��$�(M� XFGQIT� �� ��

�FG����%�� �%���577 5� *�7���

���2.(=� &1��!�L��'7F4� ��1"���<:E,Z.9\,�XKQ���!���% ��lllK\9-0t9:0K\;D���(! 5 ��16�7 5u���!�'5�$%#%��� F57 7 ����� $�#�����!��4%#������

1

13

14

25

������������ ������������������������������������������ !�"�#�

�$�����E�

� ��5��!�L� �$%#�)���=�)5�( ��7# �&�$%#��45���R�����H)��57�+9<9v�=F5�+9<9p�"�)�5

��� ���4� ��# 5����"�$uuw�16�7 5���� 5���(! 5 �$�)��� )�$u �� *�7���"���(! 7��!7F4��#�%#���>����������)�16�7��!� \<0x,�o;l��( �'5���(! "5%���16��%���v��

E����H./0�&�(1&��

E�%���H*+,&=G-D'��

�FG����<��5 ��(! ��) � *�7���

��2-�&=G-D'�

LK ����) "���+Y]QS����H&#� '����L� ���QK ��"�*�QS���#����1����Xv�n�K�XK $ n��RQSS� '����L�����NK "H)��8CY�"��� �&� '����L�"H)�����( ��������������SK "��)5 )�$u��"��5�S�����*��qK �����I�1� ��vKLEa� '����L�����pK Z;\r,<�Nv�7��'���$ n��RQSS� '����L� ���

������������ ������������������������������������������ !�"�#�

�$�����I�

��2.(=�� �5 �&1��!�Q��16��5 7 5� *%�Pi]y:�o8i���!�5��z���Pii�$%# �"��� $�#3�#H�$%#�'��%� 53�#5�"���7����'��7����1"�����'��$1"�#����G*%%���*��!����������%�#��'%�5��)��I����16��������!�'��5 )������!"��������)��� *%������� ���4$�)"�)3 �)�5� Pii� ��5����5� ��' ��7��( $�)� �)5$=#��3 �5�# 5� 5��%�) ����5�Pii��%��5�����

������� ��

�FG����B�Pi]y:�o8i�xLKv�

�� �&1��!�Q���= {����16��5���(! ��) ���)577 5�+YQS�����RQSS�$%%�5�5��!�S��(����I����(! ����)57�+YQS����$ n��RQSS�

��� ��������!"#$ ��� ��������%�&�'#$$�� N�(� �+��� ���+� �(�M� ����� �)�#� (N�$� ($�N� (#��+� $���� M��#� ���

������������ ������������������������������������������ !�"�#�

�$�����J�

E�<�-�������)&��K<II��

��5 ����)���3 7 5���(! ��) 7 5���4� � �&)��!$ n��RQSS���!3�#�'�����������'5�7 5 �1��*�) �)�5 ����4���F!5��3�#�RQSS� ��'3�#���=7��1���7 5� *�$%#����)�%���( �1���"�#�� *�7�� ����)��7 5���>�)57# �&�����5�R����� F5��������������5�7�%��I��"�)=#�# 5���%�) ��� �1��*��!����)�R�������)���# 5� )�7# �&� ������*"���%��%�%%�� '����R����"�#��)5 �$1��5����*��!�������'"��)57 5�� %$u�R�%�5�nF!5 ����) ��# 53�#�Lq����3���������nF!5��(! �3�#�RQSS� ��'3�#���=������ �1��*$%#=F5�QN�����H)��5� *�� [�� *��Y�"��� *��C��"�)��� *���7�%�R������7 5$ n��RQSS�

$ n��RQSS���7�%�Nv�7��%�"�)��7��4�����#��!%�5�5��!�q��%����=�'��%���%���%�) $%# ���N����%H)��57��!�R�"���M���(! ��( �� *��'5��16�� *�� [�Y[�C��( � *�������7 5�RQSS�%�5�5��!�p�"����=�'��%���%��'5�$%#�X����%�%�5��!$%# {���3��5��!�R��(����J���#��!77 5$ n��RQSS�

��� ����� ���������+� &1�=&1(=&1�=&1)��#�+)� &1#=&1�=&1M=&1+��$�(M� &�)=&��=&�(=&��=&�+=&�M=&��=&�#��)��#� &�#=&��=&�M=&�+=&��=&�(=&��=&�)�(#��+� ;3<3)=�;3<3�=�;3<3(=�;3<3�=�;3<3+=�;3<3M=�;3<3�=�;3<3#�M� EY;�:Y53TA��� E�"�:�ZUS�"5J5O<5TA���� E[Y�:[FU<5A�$�N� 1)=�1��:�8����/�#�>�?@��A��M� Y2"2'�#� X\;��(�� ]���:6M];�A�

�(����L���'��%� *�7 5$ n��RQSS�() (* ������ )� )� �����1�)� �� ��������� )� ��������� �� ��������� �

�(����K����%��'5�7 5$ n��RQSS�+��, ������ )� �����1=�=��>.� ISQ<���_��!Q<SQ<��� �����1�-9?���>.� ISQ<���_��!Q<SQ<������������>.����������@������,/07� 89�(� �����1�>.��C/�UISQ<�-9?�!Q<SQ<����KL7�������@�����>.����������@������,/

07� 89�

��

������������ ������������������������������������������ !�"�#�

�$�����L�

�� ��5��!�p� ����)�RQSS���4���=�'5�$%#�X����%��%�"�)�����%��4�� *� '=&�3�#3�#�'��#��!"���)5���$1����!55���(! ��( ����%��4���=���'�%���)5�'��!5$1��!� *�������7 5$ n��RQSS���������7 5"�)�����%�5��!���3��5��!�M��)���������%��4��16����5��!�Lv��(����M�7# �&��'���� *�������7 5$ n��RQSS����,��� � ������ ��� ���-)� &�)�&��� )�a�GQ<SQ<�=���a�UISQ<��� &�)�&�#� )�a�GQ<SQ<�=���a�UISQ<�(� �� �0�/�&�� )�a��� ��)=���a��� ����:�8����/�$�>�?@��A��� &�+�&�#� )�a�GQ<SQ<�=���a�UISQ<�+� &1)�&1#� )�a�GQ<SQ<�=���a�UISQ<�M=�� �� �0�/�&1� �8����/��)�>�?@���#� 1O<Ub5� )�a�B ,���/�.�=���a����/�.�

��(����%N���'��%���%7 5$ n��RQSS�

� �$ � �. +��,������������/��0�()� )� �� ��)�)� �� �� ������ )� �� ��(��� �� �� ��(�

��

I��-��1�&&-A��)$&�F+��

��(! 5 ��+,-./0��16����"1��z1���"�����5���=��"��$�)���'��!5�'�����(! ��) ������7 5�YObZ��3�#�%�5��4�� F5�# 5�7����1"���) ��'�����%�) ���� *�7F4�� 5��1"���) ��'����)57# �&�7�%�L�$��* ��5� *��7���$%#%�5��4��

Procedure OutPortB(portid : integer; value : byte); 1�������2���,'� �%� ��/��0�������-+, ������3456789Begin

1*:�����,;��!<��=���/��0������������ ,���#:+����>��������?@ABC%���=�;�(DE:���>��>��(D%����/��0�!<9

Asm Mov eax, portid Mov al, value Out dx,al End; End;

��)���1"���) ��'�����7# �&�7�%�L�$��* �� *��7���$%#%�5��4�

������������ ������������������������������������������ !�"�#�

�$�����K�

� Function InPortB(portid : integer):byte; 1��������2����,'� �>��/��0�������-+, ������3456789Var Value : byte; Begin

1*:�����,;��!<��=���/��0������������ ,���#:������>��/��0�!<����=�;�(DE:+����>��(D����=�;�������?@ABC9

Asm Mov eax, portid In al, dx Mov value, al End;

1F:G���9InPortB := value;

End;

�� ��(! ���1"���) ��'����7�����( �)57# �&�$1��!� *������1"���) � )���( ��7# �&� �� *�"�#��7�4�� ��) $1��!� ��# 5���( ���{����!5 )���(! ��%�) ����RQSS���

J��OP�4�Q�4���

J�%�-�������)&��OP�4�Q�4���� ��(! 5 ����1���������45"�)�k0BV;lA�Wi>Qvvv>m8�"���QvvX� �( 3��)��)��4�$�)� �3�#H&#�7����1"����=��!55���%�) ���G*%"�*$%#�%��5���7����1"�� F5n��n# �7F4����(! 5 �H&#�7����1"�� ��# 5�#5�1"�� �������F!5��!�16��)��7 5��%�) ���$%�� *7 5� *���!�# 5��"�#���) ��7����1"����%�) ����1"���)����4� ��� %��F!5�nF!5��7����1"��3���4���!��%�) ������$%�� *��4������n��n# �"���# 5����%��|��)5����1j ������z��$���n u�*7��)����|���4"���)5������)����|��1"��1������45��!"�)�%����4����� �3�#���%3�#5�$%#u����

"�) �)5$�I%��$%#��H&#3 ��2����)���!$%#��|��)����(! ��) 3�#�3�#5����F!53����?�H&#3 ��2��!H���( ��3�#5��( ����+9-,� g;T,:<A� ��!$%#�7����1"��"��������*H)����++}��+:K� +;TTA� };E:B9-A~�lllKVVyK\;D���)������1"���# ��&)�( �3�#5���4���=�%��*���%$%# ���I�7 5�Pii������

J�<�-�./0�&�(1&-���OP�4�Q�4���

�� ����!����$����dA,:�8;:<� �$%#�)�3���7����1"��%#���+,-./0���4� ��# 5���)��7 5���!��#��'5�%�5�1"���) ��) $1��4�

������������ ������������������������������������������ !�"�#�

�$�����M�

Function StartUpIOPorts( PortToAccess : integer) : Boolean; Var hUserPort : THandle; Begin 1*:����(H67?C+������IJC5K4569 hUserPort := CreateFile(’\\.\UserPort’, GENERIC_READ, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); CloseHandle(hUserPort); // Activate the driver 1#:��9

Sleep(100);

1E:�,������������9

Try 1E:*:��������2�>��/��0�����������9

InPortB(PortToAccess); 1E:#:���������L���������������������MNK456"��%,���,����IJC5K456��O�(H67?C�����=>>P�G�����Q�65BC9

StartUpIOPorts := true; Except

1E:E:���%��L���������������������MNK456"��%,���,����IJC5K456��O�(H67?C%�������=>>P�����;����,�����������������������R@7AC8����G�����Q�S@AJC9

ShowMessage(’Failed’); StartUpIOPorts := false; End; End;

�� ��%� ���'5�7 5uj5�*����7���$%#%�5��4��

procedure TformMain.btnConnectClick(Sender: TObject); var

PortB, PortC,PortS : integer; 1"@JCTU4N654ATV6@6BJ9 value : byte; begin 1*:���>��������G��;W�DKX;,9 if (cbLPT.ItemIndex = 0) �then PortB := $378 else PortB := $278; �1#:���>������IJC5K456��������G�%��9 if (StartUpIOPorts(PortB)) then begin ShowMessage(’Success’); end; end;

������������ ������������������������������������������ !�"�#�

�$�����%N�

L��(��&21��RG*-���� ��� �)5�1"��3��������4 ��16���� � ����(! ��) ���� *� �����)��=�)5 �$1$%#�( $�)��)��4��=#�1"��$�)uw 57# H�%��%3%?��I"�%5�)��# �"�#��'������!55�3�7�4��) $1�"�)=#��7# H%��%7 3�#H&# )��� � ��) ��)�����7�)�'"��)57 5� *���4�=&��# 5�( $�)�=#H�%��%3�#"�#$73�#=&��# 5�����) ���( =#=&��# 5"�#��'5�$�)$%#���k0BV;lA�m8��I7 3�#�� � ���'5�7 5�EA,:�8;:<�%#���)$%#=&�����3�#5��( ��5��� 3���� �)5�1"������'��%�)���������7 5���=�� $�#%�5��4��R45Y�3S<UGI� �����L_�� �,�@������0.�.�\3c5� VGFcd3UI�[UT<Z� +M)�e5UfZ<� �))�

�"B664N*�3S<UGI� g�GII5O<�\3c5� H<I�GII5O<�[UT<Z� #M�e5UfZ<� (M�

�"B664N#�3S<UGI� 2ghU<�\3c5� H<I2hU<�[UT<Z� #M�e5UfZ<� (M�

�U4YZ4Z4['5h<� �"<RJ5� O4;FGS;GiI%U4<�[UT<Z� �()�\3c5� OH%&'�

�D@ZCA�3S<UGI� ��������7�/@������,��

�FG����E���# ��� �)5�1"���

KKK�

������������ ������������������������������������������ !�"�#�

�$�����%%�

���2.(=� � �����!$�)�# 5���&���(! 5����5��(! %&�)� *��o8i�7 5���4� �&)��!�'"��)53%����=&#$%#%#����7#$1��!� ZUA<,D� � ��7#��!� C;B<:;-� 89B,-� �( ����%7���!� U� C;D.E<,:� "�#���( ��8:;.,:<0,A��%�5&1��!�S�"�#�3�#������!"�I���9:Vl9:,����5 ���4�������!1�f��+,x0\,� 9B9t,:� �����#�)5%�5&1��!�q�3�#������!�)��7 5�8;:<A��Cb �h�o8i�� ������PC8�8:0B<,:�8;:<��o8iL��� ���43�#%������������(! �7#�&)��#�)5"�%5���� ��%��&1��!�p����(! ��#�)51��3�#������!"�I��g,A;E:\,� ������� ��%77 5�'"��)5� *�3�#�����

����� �FG����I���#�)5�ZUA<,D�"����9:Vl9:,�

������FG����J���#�)5�+,x0\,� 9B9t,:�

������������ ������������������������������������������ !�"�#�

�$�����%<�

����� �FG����L���#�)5�PC8�8:0B<,:�8;:<�8:;.,:<0,A�

�� 3���7����1"����4�� ��# 5"���)��7 5���(! ��) ���� *�7�� � ��1"������7 5�+,-./0�%#��������4� F5�# 5���dB0<��'�����%�) ���� *���%�H�$%#�'� ���� �)57 5�dA,:8;:<�nF!5���(! �)�0;.;:<K.9A�"��H�$%#�'�1��"�#$7 ����I��# ���(! 3�#�'��( ���k9:B0Bt����%$1���#%�1"��7 5"uw������� ��%%�5��4��

unit IOPort; interface uses windows; procedure outport(portid : integer; value : integer); procedure outportb(portid : integer; value : BYTE); function inportb(portid : integer) : byte; function inport(portid : integer) : integer; function StartUpIoPorts(PortToAccess : integer) : boolean; implementation var bPrivException : boolean; procedure outport(portid : integer; value : integer); Begin asm mov edx,portid; mov eax,value; out dx,ax; end; end;

������������ ������������������������������������������ !�"�#�

�$�����%B�

procedure outportb(portid : integer; value : BYTE); Begin asm mov edx,portid mov al,value out dx,al end; end; function inportb(portid : integer) : byte; Var value : byte; Begin asm mov edx,portid in al,dx mov value,al end; inportb := value; end; function inport(portid : integer) : integer; Var value : integer; Begin value := 0; asm mov edx,portid in ax,dx mov value,eax end; inport := value; end; function StartUpIoPorts(PortToAccess : integer) : boolean; Var hUserPort : THandle; Begin hUserPort := CreateFile('\\.\UserPort', GENERIC_READ, 0, nil,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); CloseHandle(hUserPort); Sleep(100); try inportb(PortToAccess); bPrivException := false; except MessageBox(0,'Failed','Failes',MB_OK); bPrivException := true; end; Result := not bPrivException; end; end.

�� ���#%%#��� ����)����'��#��!����5�� � ���'5��dA,:8;:<�"����>�)57# �&� �� *���)��4����5$�)���)���������RQSS���! ��# 53�#�16������%�) ��� �1��*��� ��

������������ ������������������������������������������ !�"�#�

�$�����%E�

�� 3���45�) ?$1� �1��1�5��#%7 5�&����0;.;:<� 3�#����������'5�7 5� RQSS� "����=��!55��'�����"���)57# �&�H)��5�RQSS�nF!5��1�����*�) �������G*%"�*�) $13� ����� ��%�#��16��1"������7 5�1"����� �)5�nF!5 �%�'��2�( ��# 5����3�#�&����0;.;:<�3��)��7 5�EA,A�%#����� �"�������45��!�����%�) ����0;.;:<������! ��� � �%#��uj5�*����Z<9:<d.Ob8;:<A���� ���(! ����)$%�� *�dA,:8;:<� �=&���������'5��nF!5 ��16�H��'3�#�1"���'5�H�%��%$%#��

unit UnitMain; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, ioport; type TformMain = class(TForm) Label1: TLabel; cbLPT: TComboBox; btnConnect: TButton; btnExit: TButton; procedure FormCreate(Sender: TObject); procedure btnExitClick(Sender: TObject); procedure btnConnectClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var formMain: TformMain; implementation {$R *.dfm} procedure TformMain.FormCreate(Sender: TObject); 1���������G��\��0��2������9begin 1*:�/ ���� �������%����U4YZ4"4[��Q������DKX*���DKX#9 cbLPT.Items.Add('LPT1'); cbLPT.Items.Add('LPT2'); 1#:�����,���� �������Q������DKX*9 cbLPT.ItemIndex := 0; end;

������������ ������������������������������������������ !�"�#�

�$�����%I�

procedure TformMain.btnExitClick(Sender: TObject); begin 1���������G�������� �����-]� [769 Application.Terminate; end;

procedure TformMain.btnConnectClick(Sender: TObject); 1���������G�������� �����-]�U4NNCH69var PortB : integer; begin 1*:���>������L2�;W���G��;W�/��0�;,���M6CYMN8C[��Q�)��,������G��;W�DKX*��������,������������Q�_E '��������G������L2�����%��;W�/��0���O�=����������� �����Q����G��a%,��������������9 if (cbLPT.ItemIndex = 0) then

PortB := $378 else

PortB := $278; 1#:���>������IJC5K456��������G�%������������=��,������������VBHHCJJ9 if (StartUpIOPorts(PortB)) then begin ShowMessage('Success'); end; end; end.��

K���=G��� ������� ���4H&#�7������5�)H&# )��) ���=�#5� *%�'�����(! ��) ���� *�7���"���7����1"����(! �) ���� *%%#���+,-./0�����'�I �3������� ��) $1 ��16��(! 57 5��������oP+� '���"1%�� %��%���� �)5�1"�� ���%#������N���� �)5�( �� � ]��1�%1�%$u���'��%�

]$u������� � ]$u��!5 �n#�$17��� � ]$u��!5 ��5��5$1n#�7��� ��(! ��=�������� %�oP+� $%#"�#��3���1%�*�) $1 ��16��(! 57 5�������� �� *��"��5[� � �� *"�����I1� �Z<,..0Bt� D;<;:�[� p]Z,tD,B<� L� ����[�"������*����5 ���4��16���7����1"����7# �&� ������*"���%��%1�) �%���"��� ����������*���%�#�7 5�������%��4 ��16���� �)5��55���!��7# �&� �����������*"�#��'�����!����� � ����@�7# �&�=#���I�5�H�����p�Z,tD,B<�� ��%�#���47 7 ����� ����[����5��Pii�"������ ��� �����H����16� �)5����!��5��������3�#H�$%#�7���������) $1�"�����5 �����&#���!������ *�7����� ���N�� ������N��%( �������( ����"G��"�)"1���%����I��%�N��%( �"�#��)������� �����45��#�����7����1"����!55��� %�oP+����H��