Board logo

标题: 从网上找的代码,不知道是干什么用 [打印本页]

作者: 258369    时间: 2009-8-7 21:23     标题: 从网上找的代码,不知道是干什么用

有条件的编译试试看吧,我也不知道是干什么的,反正代码挺多的

  1. Option Explicit
  2.   Public Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
  3.   Public Declare Function LoadIcon Lib "user32" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As String) As Long
  4.   Public Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As String) As Long
  5.   Public Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
  6.   Public Declare Function RegisterClassEx Lib "user32" Alias "RegisterClassExA" (pcWndClassEx As WNDCLASSEX) As Integer
  7.   Public Declare Function ShowWindow Lib "user32" (ByVal handle_of_window As Long, ByVal nCmdShow As Long) As Long
  8.   Public Declare Function UpdateWindow Lib "user32" (ByVal handle_of_window As Long) As Long
  9.   Public Declare Function SetFocus Lib "user32" (ByVal handle_of_window As Long) As Long
  10.   Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal handle_of_window As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  11.   Public Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal handle_of_window As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  12.   Public Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As MSG, ByVal handle_of_window As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
  13.   Public Declare Function TranslateMessage Lib "user32" (lpMsg As MSG) As Long
  14.   Public Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As MSG) As Long
  15.   Public Declare Sub PostQuitMessage Lib "user32" (ByVal nExitCode As Long)
  16.   Public Declare Function BeginPaint Lib "user32" (ByVal handle_of_window As Long, lpPaint As PAINTSTRUCT) As Long
  17.   Public Declare Function EndPaint Lib "user32" (ByVal handle_of_window As Long, lpPaint As PAINTSTRUCT) As Long
  18.   Public Declare Function GetClientRect Lib "user32" (ByVal handle_of_window As Long, lpRect As RECT) As Long
  19.   Public Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
  20.   
  21.   
  22.   Type WNDCLASSEX
  23.    cbSize As Long
  24.    style As Long
  25.    lpfnWndProc As Long
  26.    cbClsExtra As Long
  27.    cbWndExtra As Long
  28.    hInstance As Long
  29.    hIcon As Long
  30.    hCursor As Long
  31.    hbrBackground As Long
  32.    lpszMenuName As String
  33.    lpszClassName As String
  34.    hIconSm As Long
  35.   End Type
  36.   Type POINTAPI
  37.    x As Long
  38.    y As Long
  39.   End Type
  40.   Type MSG
  41.    handle_of_window As Long
  42.    message As Long
  43.    wParam As Long
  44.    lParam As Long
  45.    time As Long
  46.    pt As POINTAPI
  47.   End Type
  48.   Type RECT
  49.    Left As Long
  50.    Top As Long
  51.    Right As Long
  52.    Bottom As Long
  53.   End Type
  54.   Type PAINTSTRUCT
  55.    hdc As Long
  56.    fErase As Long
  57.    rcPaint As RECT
  58.    fRestore As Long
  59.    fIncUpdate As Long
  60.    rgbReserved(32) As Byte 'this was declared incorrectly in VB API viewer
  61.   End Type
  62.   Public Const WS_VISIBLE As Long = &H10000000
  63.   Public Const WS_VSCROLL As Long = &H200000
  64.   Public Const WS_TABSTOP As Long = &H10000
  65.   Public Const WS_THICKFRAME As Long = &H40000
  66.   Public Const WS_MAXIMIZE As Long = &H1000000
  67.   Public Const WS_MAXIMIZEBOX As Long = &H10000
  68.   Public Const WS_MINIMIZE As Long = &H20000000
  69.   Public Const WS_MINIMIZEBOX As Long = &H20000
  70.   Public Const WS_SYSMENU As Long = &H80000
  71.   Public Const WS_BORDER As Long = &H800000
  72.   Public Const WS_CAPTION As Long = &HC00000 ' WS_BORDER Or WS_DLGFRAME
  73.   Public Const WS_CHILD As Long = &H40000000
  74.   Public Const WS_CHILDWINDOW As Long = (WS_CHILD)
  75.   Public Const WS_CLIPCHILDREN As Long = &H2000000
  76.   Public Const WS_CLIPSIBLINGS As Long = &H4000000
  77.   Public Const WS_DISABLED As Long = &H8000000
  78.   Public Const WS_DLGFRAME As Long = &H400000
  79.   Public Const WS_EX_ACCEPTFILES As Long = &H10&
  80.   Public Const WS_EX_DLGMODALFRAME As Long = &H1&
  81.   Public Const WS_EX_NOPARENTNOTIFY As Long = &H4&
  82.   Public Const WS_EX_TOPMOST As Long = &H8&
  83.   Public Const WS_EX_TRANSPARENT As Long = &H20&
  84.   Public Const WS_GROUP As Long = &H20000
  85.   Public Const WS_HSCROLL As Long = &H100000
  86.   Public Const WS_ICONIC As Long = WS_MINIMIZE
  87.   Public Const WS_OVERLAPPED As Long = &H0&
  88.   Public Const WS_OVERLAPPEDWINDOW As Long = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
  89.   Public Const WS_POPUP As Long = &H80000000
  90.   Public Const WS_POPUPWINDOW As Long = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
  91.   Public Const WS_SIZEBOX As Long = WS_THICKFRAME
  92.   Public Const WS_TILED As Long = WS_OVERLAPPED
  93.   Public Const WS_TILEDWINDOW As Long = WS_OVERLAPPEDWINDOW
  94.   Public Const CW_USEDEFAULT As Long = &H80000000
  95.   Public Const CS_HREDRAW As Long = &H2
  96.   Public Const CS_VREDRAW As Long = &H1
  97.   Public Const IDI_APPLICATION As Long = 32512&
  98.   Public Const IDC_ARROW As Long = 32512&
  99.   Public Const WHITE_BRUSH As Integer = 0
  100.   Public Const BLACK_BRUSH As Integer = 4
  101.   Public Const WM_KEYDOWN As Long = &H100
  102.   Public Const WM_CLOSE As Long = &H10
  103.   Public Const WM_DESTROY As Long = &H2
  104.   Public Const WM_PAINT As Long = &HF
  105.   Public Const SW_SHOWNORMAL As Long = 1
  106.   Public Const DT_CENTER As Long = &H1
  107.   Public Const DT_SINGLELINE As Long = &H20
  108.   Public Const DT_VCENTER As Long = &H4
  109.   Sub Main()
  110.   Call vbWinMain
  111.   End Sub
  112.   Public Function vbWinMain() As Long
  113.    Const CLASSNAME = "hello_world_vb"
  114.    Const TITLE = "hello, world!"
  115.    Dim handle_of_window As Long
  116.    Dim window_class As WNDCLASSEX
  117.    Dim message As MSG
  118.    window_class.cbSize = Len(window_class)
  119.    window_class.style = CS_HREDRAW Or CS_VREDRAW
  120.    window_class.lpfnWndProc = GetFuncPtr(AddressOf WindowProc)
  121.    window_class.cbClsExtra = 0&
  122.    window_class.cbWndExtra = 0&
  123.    window_class.hInstance = App.hInstance
  124.    window_class.hIcon = LoadIcon(App.hInstance, IDI_APPLICATION)
  125.    window_class.hCursor = LoadCursor(App.hInstance, IDC_ARROW)
  126.    window_class.hbrBackground = GetStockObject(WHITE_BRUSH)
  127.    window_class.lpszMenuName = 0&
  128.    window_class.lpszClassName = CLASSNAME
  129.    window_class.hIconSm = LoadIcon(App.hInstance, IDI_APPLICATION)
  130.   
  131.    RegisterClassEx window_class
  132.   
  133.    handle_of_window = CreateWindowEx(0&, CLASSNAME, TITLE, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0&, 0&, App.hInstance, 0&)
  134.   
  135.    ShowWindow handle_of_window, SW_SHOWNORMAL
  136.    UpdateWindow handle_of_window
  137.    SetFocus handle_of_window
  138.    Do While 0 <> GetMessage(message, 0&, 0&, 0&)
  139.    TranslateMessage message
  140.    DispatchMessage message
  141.    Loop
  142.   
  143.    vbWinMain = message.wParam
  144.   End Function
  145.   Public Function WindowProc(ByVal handle_of_window As Long, ByVal message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  146.    Dim ps As PAINTSTRUCT
  147.    Dim rc As RECT
  148.    Dim hdc As Long
  149.    Dim str As String
  150.    Select Case message
  151.    Case WM_PAINT
  152.    hdc = BeginPaint(handle_of_window, ps)
  153.    Call GetClientRect(handle_of_window, rc)
  154.    str = "hello, world!"
  155.    Call DrawText(hdc, str, Len(str), rc, DT_SINGLELINE Or DT_CENTER Or DT_VCENTER)
  156.    Call EndPaint(handle_of_window, ps)
  157.    Exit Function
  158.   
  159.    'Case WM_KEYDOWN
  160.    ' Call PostMessage(handle_of_window, WM_CLOSE, 0, 0)
  161.    ' Exit Function
  162.   
  163.    Case WM_DESTROY
  164.    PostQuitMessage 0&
  165.    Exit Function
  166.   
  167.    Case Else
  168.    WindowProc = DefWindowProc(handle_of_window, message, wParam, lParam)
  169.    End Select
  170.   End Function
  171.   Function GetFuncPtr(ByVal lngFnPtr As Long) As Long
  172.    GetFuncPtr = lngFnPtr
  173.   End Function
复制代码

作者: airplane    时间: 2009-8-8 11:16

hello world
作者: h847670898    时间: 2009-8-8 18:35

yun
作者: 那巴尔    时间: 2009-10-19 12:01

像押韵的诗歌,我是不是幻觉了……?
作者: april    时间: 2009-11-5 09:20

我就知道 document.write("Hello World!") 




欢迎光临 世界之窗论坛 (http://bbs.theworld.cn/) Powered by Discuz! 7.2