Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7126800
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2010-05-21 10:56:37

REPORT z_barry_test NO STANDARD PAGE .

DATA: value TYPE ,
      server TYPE string.
DATA matcher TYPE REF TO cl_abap_matcher.

PARAMETERS: p_host(15) TYPE ,
            p_port(8) TYPE n .

INITIALIZATION.
  CALL METHOD cl_gui_frontend_services=>registry_get_dword_value
    EXPORTING
      root      = cl_gui_frontend_services=>hkey_current_user
      key       'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
      value     'ProxyEnable'
    IMPORTING
      reg_value = value
    EXCEPTIONS
      OTHERS    1.

  CALL METHOD cl_gui_frontend_services=>registry_get_value
    EXPORTING
      root      = cl_gui_frontend_services=>hkey_current_user
      key       'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
      value     'ProxyServer'
    IMPORTING
      reg_value = server
    EXCEPTIONS
      OTHERS    1.

  CALL METHOD cl_gui_cfw=>flush.
  IF NOT server IS INITIAL.
    SPLIT server AT ':' INTO p_host p_port.
  ENDIF.

AT SELECTION-SCREEN.
  IF sy-ucomm = 'ONLI' AND NOT p_host IS INITIAL.
    matcher = cl_abap_matcher=>create( pattern = '\d+\.\d+\.\d+\.\d+'
                                   ignore_case = 'X'
                                   text = p_host ).
    IF matcher->match( ) IS INITIAL.
      MESSAGE 'Wrong IP Addr Format' TYPE 'E'.
    ENDIF.
  ENDIF.

START-OF-SELECTION.
  IF p_host = ''.
    CALL METHOD cl_gui_frontend_services=>registry_set_dword_value
      EXPORTING
        root        = cl_gui_frontend_services=>hkey_current_user
        key         'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
        value       'ProxyEnable'
        dword_value = 0
      IMPORTING
        rc          = value
      EXCEPTIONS
        OTHERS      4.
  ELSE.
    SHIFT p_port LEFT DELETING LEADING '0' .
    CONCATENATE p_host':' p_port INTO server.

    CALL METHOD cl_gui_frontend_services=>registry_set_dword_value
      EXPORTING
        root        = cl_gui_frontend_services=>hkey_current_user
        key         'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
        value       'ProxyEnable'
        dword_value = 1
      IMPORTING
        rc          = value
      EXCEPTIONS
        OTHERS      4.
    CALL METHOD cl_gui_frontend_services=>registry_set_value
      EXPORTING
        root       = cl_gui_frontend_services=>hkey_current_user
        key        'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
        value_name = 'ProxyServer'
        value      = server
      IMPORTING
        rc         = value
      EXCEPTIONS
        OTHERS     5.
  ENDIF.
  CALL METHOD cl_gui_cfw=>flush.

  MESSAGE s000(oo) WITH 'OK!'.
阅读(2988) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~