小弟想将IdUDPServer封装成dll
可是初始化却不成功,请高手指教!定义:
private
  IdUDPServer1: TIdUDPServer;函数里这样创建:
IdUDPServer1:= TIdUDPServer.Create(self);每次测试程序调用到创建IdUDPServer1时就出错,发现错出在
function TIdSocketHandles.Add: TIdSocketHandle;
begin
  Result := Inherited Add as TIdSocketHandle;
  Result.Port := DefaultPort;
end;

解决方案 »

  1.   

    date/time         : 2006-06-13, 14:01:27, 294ms
    computer name     : ZEUS
    user name         : zeus <admin>
    operating system  : Windows XP Service Pack 2 build 2600
    system language   : Chinese
    system up time    : 5 hours 31 minutes
    program up time   : 29 seconds
    processor         : Intel(R) Pentium(R) M processor 1500MHz
    physical memory   : 73/255 MB (free/total)
    free disk space   : (C:) 2.01 GB (D:) 1.26 GB
    display mode      : 1024x768, 32 bit
    process id        : $c90
    allocated memory  : 11.00 MB
    executable        : Project1.exe
    exec. date/time   : 2006-06-13 09:09
    madExcept version : 3.0
    callstack crc     : $44c06ce2, $2840dab0, $2840dab0
    exception class   : EAccessViolation
    exception message : Access violation at address 024E2E88 in module 'list.dll'. Write of address 0000004C.main thread ($2f8):
    024e2e88 +014 list.dll     UnitList 296 +1 TUnitUser.TCPServerCreate
    024e2faf +007 list.dll     list      49 +0 CTCPServerCreate
    00496c8a +01e Project1.exe Unit1     51 +1 TForm1.CheckBox2Click
    0047755c +064 Project1.exe Controls        TControl.Click
    0046fd48 +00c Project1.exe StdCtrls        TCustomCheckBox.Click
    0046fdcd +049 Project1.exe StdCtrls        TCustomCheckBox.SetState
    0046fd23 +027 Project1.exe StdCtrls        TCustomCheckBox.Toggle
    0046ff21 +009 Project1.exe StdCtrls        TCustomCheckBox.CNCommand
    004773c4 +188 Project1.exe Controls        TControl.WndProc
    0047a2cf +157 Project1.exe Controls        TWinControl.WndProc
    0046fba8 +06c Project1.exe StdCtrls        TButtonControl.WndProc
    00477194 +024 Project1.exe Controls        TControl.Perform
    0047a407 +023 Project1.exe Controls        DoControlMsg
    0047aa5f +00b Project1.exe Controls        TWinControl.WMCommand
    00490ff0 +02c Project1.exe Forms           TCustomForm.WMCommand
    004773c4 +188 Project1.exe Controls        TControl.WndProc
    0047a2cf +157 Project1.exe Controls        TWinControl.WndProc
    0048f049 +421 Project1.exe Forms           TCustomForm.WndProc
    00479f4c +02c Project1.exe Controls        TWinControl.MainWndProc
    00461158 +014 Project1.exe Classes         StdWndProc
    7c92eae0 +010 ntdll.dll                    KiUserCallbackDispatcher
    77d1b8fe +044 user32.dll                   SendMessageW
    77d1e900 +016 user32.dll                   CallWindowProcA
    0047a3b3 +0d7 Project1.exe Controls        TWinControl.DefaultHandler
    00477964 +010 Project1.exe Controls        TControl.WMLButtonUp
    004773c4 +188 Project1.exe Controls        TControl.WndProc
    0047a2cf +157 Project1.exe Controls        TWinControl.WndProc
    0046fba8 +06c Project1.exe StdCtrls        TButtonControl.WndProc
    00479f4c +02c Project1.exe Controls        TWinControl.MainWndProc
    00461158 +014 Project1.exe Classes         StdWndProc
    77d196c2 +00a user32.dll                   DispatchMessageA
    0049535f +083 Project1.exe Forms           TApplication.ProcessMessage
    0049537e +00a Project1.exe Forms           TApplication.HandleMessage
    0049559e +096 Project1.exe Forms           TApplication.Run
    00497017 +03b Project1.exe Project1  17 +3 initializationmodules:
    00400000 Project1.exe                 D:\Project\GPS\list_dll
    02440000 list.dll                     D:\Project\GPS\list_dll
    02520000 borlndmm.dll 7.0.4.453       C:\Program Files\Borland\Delphi7\Bin
    37210000 CnsMin.dll   1.5.3.1         C:\WINDOWS\DOWNLO~1
    5adc0000 uxtheme.dll  6.0.2900.2180   C:\WINDOWS\system32
    5d170000 comctl32.dll 5.82.2900.2180  C:\WINDOWS\system32
    5fdd0000 NETAPI32.dll 5.1.2600.2180   C:\WINDOWS\system32
    62c20000 LPK.DLL      5.1.2600.2180   C:\WINDOWS\system32
    71a10000 WS2HELP.dll  5.1.2600.2180   C:\WINDOWS\system32
    71a20000 WS2_32.dll   5.1.2600.2180   C:\WINDOWS\system32
    71a40000 wsock32.dll  5.1.2600.2180   C:\WINDOWS\system32
    73640000 msctfime.ime 5.1.2600.2180   C:\WINDOWS\system32
    73fa0000 USP10.dll    1.420.2600.2180 C:\WINDOWS\system32
    76300000 IMM32.DLL    5.1.2600.2180   C:\WINDOWS\system32
    76320000 comdlg32.dll 6.0.2900.2180   C:\WINDOWS\system32
    765e0000 CRYPT32.dll  5.131.2600.2180 C:\WINDOWS\system32
    76990000 ole32.dll    5.1.2600.2726   C:\WINDOWS\system32
    76bc0000 psapi.dll    5.1.2600.2180   C:\WINDOWS\system32
    76c00000 WINTRUST.dll 5.131.2600.2180 C:\WINDOWS\system32
    76c60000 imagehlp.dll 5.1.2600.2180   C:\WINDOWS\system32
    76db0000 MSASN1.dll   5.1.2600.2180   C:\WINDOWS\system32
    770f0000 oleaut32.dll 5.1.2600.2180   C:\WINDOWS\system32
    77180000 comctl32.dll 6.0.2900.2180   C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9
    77bd0000 version.dll  5.1.2600.2180   C:\WINDOWS\system32
    77be0000 msvcrt.dll   7.0.2600.2180   C:\WINDOWS\system32
    77d10000 user32.dll   5.1.2600.2622   C:\WINDOWS\system32
    77da0000 advapi32.dll 5.1.2600.2180   C:\WINDOWS\system32
    77e50000 RPCRT4.dll   5.1.2600.2180   C:\WINDOWS\system32
    77ef0000 GDI32.dll    5.1.2600.2818   C:\WINDOWS\system32
    77f40000 SHLWAPI.dll  6.0.2900.2861   C:\WINDOWS\system32
    77fc0000 Secur32.dll  5.1.2600.2180   C:\WINDOWS\system32
    7c800000 kernel32.dll 5.1.2600.2180   C:\WINDOWS\system32
    7c920000 ntdll.dll    5.1.2600.2180   C:\WINDOWS\system32
    7d590000 shell32.dll  6.0.2900.2869   C:\WINDOWS\system32processes:
    000 Idle
    004 System          normal
    278 smss.exe        normal C:\WINDOWS\system32
    2b0 csrss.exe       normal C:\WINDOWS\system32
    2c8 winlogon.exe    high   C:\WINDOWS\system32
    2f4 services.exe    normal C:\WINDOWS\system32
    300 lsass.exe       normal C:\WINDOWS\system32
    39c Ati2evxx.exe    normal C:\WINDOWS\system32
    3a8 svchost.exe     normal C:\WINDOWS\system32
    3f8 svchost.exe     normal C:\WINDOWS\system32
    480 CCenter.exe     normal C:\Program Files\Rising\Rav
    490 svchost.exe     normal C:\WINDOWS\System32
    4e0 svchost.exe     normal C:\WINDOWS\system32
    548 svchost.exe     normal C:\WINDOWS\system32
    578 Ravmond.exe     normal C:\Program Files\Rising\Rav
    5dc rfwsrv.exe      normal c:\program files\rising\rfw
    630 Explorer.EXE    normal C:\WINDOWS
    654 Rundll32.exe    normal C:\WINDOWS\system32
    6d0 spoolsv.exe     normal C:\WINDOWS\system32
    734 RavStub.exe     normal C:\Program Files\Rising\Rav
    7c0 RfwMain.exe     normal c:\program files\rising\rfw
    188 CDAC11BA.EXE    normal C:\WINDOWS\system32\drivers
    1b0 mysqld-nt.exe   normal C:\Program Files\MySQL\MySQL Server 5.0\bin
    1e0 rundll32.exe    normal C:\WINDOWS\system32
    22c svchost.exe     normal C:\WINDOWS\system32
    2a8 wdfmgr.exe      normal C:\WINDOWS\system32
    80c alg.exe         normal C:\WINDOWS\System32
    aa0 RavTask.exe     idle   C:\Program Files\Rising\Rav
    aec Ravmon.exe      normal C:\Program Files\Rising\Rav
    cf0 TIMPlatform.exe normal C:\Program Files\Tencent\QQ
    cf4 QQ.exe          normal C:\Program Files\Tencent\QQ
    f00 popo.exe        normal C:\Program Files\Netease\popo2004
    70c Rundll32.exe    normal C:\WINDOWS\system32
    ef0 delphi32.exe    normal C:\Program Files\Borland\Delphi7\Bin
    5d4 msnmsgr.exe     normal C:\Program Files\MSN Messenger
    350 delphi32.exe    normal C:\Program Files\Borland\Delphi7\Bin
    f48 ThunderMini.exe normal C:\Program Files\Maxthon\Thundermini
    4b8 TDUpdate.exe    normal C:\Program Files\Maxthon\Thundermini
    0dc JJSvr.EXE       normal C:\Program Files\JJOL\IME
    dc0 delphi32.exe    normal C:\Program Files\Borland\Delphi7\Bin
    c90 Project1.exe    normal D:\Project\GPS\list_dll
      

  2.   

    hardware:
    + DVD/CD-ROM 驱动器
      - Generic DVD-ROM SCSI CdRom Device
      - MATSHITA UJDA755 DVD/CDRW
    + IDE ATA/ATAPI 控制器
      - Intel(R) 82801DBM Ultra ATA Storage Controller - 24CA
      - 次要 IDE 通道
      - 主要 IDE 通道
    + IEEE 1394 总线主控制器
      - OHCI Compliant IEEE 1394 Host Controller
    + PCMCIA 卡
      - Ricoh R/RL/RT/RC/5C475(II), R5C520 or Compatible CardBus Controller
    + SCSI 和 RAID 控制器
      - D347PRT SCSI Controller
    + 处理器
      - Intel(R) Pentium(R) M processor 1500MHz
    + 磁盘驱动器
      - HITACHI_DK23FA-40
    + 电池
      - Microsoft AC Adapter
      - Microsoft ACPI-Compliant Control Method Battery
    + 监视器
      - 即插即用监视器
    + 计算机
      - Advanced Configuration and Power Interface (ACPI) PC
    + 键盘
      - 标准 101/102 键或 Microsoft 自然 PS/2 键盘
    + 人体学输入设备
      - Sony Notebook Control Device
      - Sony Programmable I/O Control Device
      - USB 人体学输入设备
    + 声音、视频和游戏控制器
      - YAMAHA AC-XG Audio Device (driver 6.13.10.3157)
      - 传统视频捕捉设备
      - 传统音频驱动程序
      - 媒体控制设备
      - 视频编码解码器
      - 音频编码解码器
    + 鼠标和其它指针设备
      - HID-compliant mouse
      - PS/2 Compatible Mouse
    + 通用串行总线控制器
      - Intel(R) 82801DB/DBM USB 2.0 Enhanced Host Controller - 24CD
      - Intel(R) 82801DB/DBM USB Universal Host Controller - 24C2
      - Intel(R) 82801DB/DBM USB Universal Host Controller - 24C4
      - Intel(R) 82801DB/DBM USB Universal Host Controller - 24C7
      - USB Mass Storage Device
      - USB Root Hub
      - USB Root Hub
      - USB Root Hub
      - USB Root Hub
    + 网络适配器
      - 1394 网络适配器 #2
      - Intel(R) PRO/100 VE Network Connection (driver 7.0.28.0)
    + 系统设备
      - ACPI Lid
      - ACPI Power Button
      - ACPI Thermal Zone
      - Direct memory access controller
      - Intel(R) 82801 PCI Bridge - 2448
      - Intel(R) 82801DB/DBM SMBus Controller - 24C3
      - Intel(R) 82801DBM LPC Interface Controller - 24CC
      - Intel(R) 82802 Firmware Hub Device
      - Intel(R) 82855PM Processor to AGP Controller - 3341
      - Intel(R) 82855PM Processor to I/O Controller - 3340
      - ISAPNP Read Data Port
      - Logical Disk Manager
      - Microcode Update Device
      - Microsoft ACPI-Compliant Embedded Controller
      - Microsoft ACPI-Compliant System
      - Microsoft Composite Battery
      - Microsoft System Management BIOS Driver
      - Motherboard resources
      - Numeric data processor
      - PCI bus
      - Plug and Play Software Device Enumerator
      - PnP BIOS Extension (driver 3.47.0.0)
      - Programmable interrupt controller
      - System CMOS/real time clock
      - System timer
      - Terminal Server Device Redirector
      - Terminal Server Keyboard Driver
      - Terminal Server Mouse Driver
      - Volume Manager
      - 控制台的全屏显示视频驱动程序
    + 显示卡
      - MOBILITY RADEON    (driver 6.14.10.6404)cpu registers:
    eax = 0253297c
    ebx = 00000000
    ecx = 024dbc90
    edx = 024e0918
    esi = 0253297c
    edi = 0012f708
    eip = 024e2e88
    esp = 0012f574
    ebp = 0012f6ccstack dump:
    0012f574  3c fd 46 00 cc 43 dc 00 - b4 2f 4e 02 90 6c 49 00  <.F..C.../N..lI.
    0012f584  62 75 47 00 cc 43 dc 00 - 4d fd 46 00 cc 43 dc 00  buG..C..M.F..C..
    0012f594  d2 fd 46 00 cc 43 dc 00 - 08 f7 12 00 28 fd 46 00  ..F..C......(.F.
    0012f5a4  27 ff 46 00 c7 73 47 00 - 08 f7 12 00 08 f7 12 00  '.F..sG.........
    0012f5b4  cc 43 dc 00 39 00 00 00 - d8 f5 12 00 20 00 00 00  .C..9...........
    0012f5c4  d0 f5 12 00 00 c0 d1 77 - 0a 80 00 00 5c f6 12 00  .......w....\...
    0012f5d4  f6 74 d2 77 0a 80 00 00 - 3c 05 0c 00 fc ff ff ff  .t.w....<.......
    0012f5e4  00 00 00 00 00 00 00 00 - e4 f6 12 00 72 6c d2 77  ............rl.w
    0012f5f4  00 00 00 00 00 00 00 00 - 00 00 00 00 64 f6 12 00  ............d...
    0012f604  f4 0d 10 81 72 10 01 38 - 05 00 00 00 3c 05 0c 00  ....r..8....<...
    0012f614  00 00 00 00 e0 f6 12 00 - 1c de fb 73 96 07 01 0f  ...........s....
    0012f624  02 00 00 00 17 00 00 00 - 60 02 ff 73 00 00 00 00  ........`..s....
    0012f634  2c f7 12 00 72 6c d2 77 - 00 00 00 00 00 00 00 00  ,...rl.w........
    0012f644  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
    0012f654  05 00 00 00 3c 05 0c 00 - 00 00 00 00 5a b0 d3 77  ....<.......Z..w
    0012f664  b8 f6 12 00 f8 fb fd 7f - 00 00 00 00 98 f6 12 00  ................
    0012f674  aa f0 92 7c 00 fc fd 7f - 34 00 00 00 a4 f6 12 00  ...|....4.......
    0012f684  9c 1c dc 00 00 00 00 00 - f8 fb fd 7f 64 f9 12 00  ............d...
    0012f694  00 00 00 00 c1 d9 92 7c - 09 cb 80 7c 00 fc fd 7f  .......|...|....
    0012f6a4  34 00 00 00 22 cb 80 7c - 64 f9 12 00 00 00 00 00  4..."..|d.......disassembling:
    [...]
    024e2e78 296   mov     ecx, ebx
    024e2e7a       mov     dl, 1
    024e2e7c       mov     eax, [$24e08cc]
    024e2e81       call    -$1fb2 ($24e0ed4)      ; IdTCPServer.TIdTCPServer.Create (list.dll)
    024e2e86       mov     esi, eax
    024e2e88     > mov     [ebx+$4c], esi
    024e2e8b 299   mov     [esi+$c4], ebx
    024e2e91       mov     dword ptr [esi+$c0], $24e26d0  ; UnitList.TUnitUser.TCPServerConnect (list.dll)
    024e2e9b 300   mov     [esi+$cc], ebx
    024e2ea1       mov     dword ptr [esi+$c8], $24e2d60  ; UnitList.TUnitUser.TCPServerDisconnect (list.dll)
    024e2eab 301   mov     [esi+$dc], ebx
    [...]
      

  3.   

    看看IdUDPServer1:= TIdUDPServer.Create(nil);好用不
      

  4.   

    试过
    还试过从test程序中传form对象