在调用windows的dll中的api函数时遇到的参数问题(100分)

  • 主题发起人 主题发起人 yhzz
  • 开始时间 开始时间
Y

yhzz

Unregistered / Unconfirmed
GUEST, unregistred user!
我在调用rasDial函数时函数原型如下:(以下为windows sdk中的描述)<br>DWORD RasDial(<br>LPRASDIALEXTENSIONS lpRasDialExtensions, // pointer to function extensions data<br>LPTSTR lpszPhonebook, // pointer to full path and filename of phone-book file<br>LPRASDIALPARAMS lpRasDialParams, // pointer to calling parameters data<br>DWORD dwNotifierType, // specifies type of RasDial event handler <br>LPVOID lpvNotifier, // specifies a handler for RasDial events<br>LPHRASCONN lphRasConn // pointer to variable to receive connection handle<br>);<br>改函数在ras.h中<br>我是否需要对照api文档把这些类型的参数定义都改成delphi的样子,然后写函数声明?<br>还有就是在api文档中介绍RASDIALPARAM类型定义时用到了 RAS_MaxEntryName这么个常数定义,quick info中写的是在ras.h中,那么我如过不装 vc的开发环境,我怎么知道<br>RAS_MaxEntryName的值是多少哈, &nbsp;如果不知道就不能把RASDIALPARAM所对应的pascal定义给写出来哈
 
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <br><br><br>Unit: Remote Access Service (RAS)<br><br>Creation: Feb 18, 1997. Translated from MS-Visual C 4.2 header files<br><br>EMail: francois.piette@pophost.eunet.be francois.piette@rtfm.be<br><br>http://www.rtfm.be/fpiette<br><br>Legal issues: Copyright (C) 1997, 1998 by Fran輟is PIETTE<br><br>Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56<br><br>&lt;francois.piette@pophost.eunet.be&gt;<br><br>This software is provided 'as-is', without any express or<br><br>implied warranty. In no event will the author be held liable<br><br>for any damages arising from the use of this software.<br><br>Permission is granted to anyone to use this software for any<br><br>purpose, including commercial applications, and to alter it<br><br>and redistribute it freely, subject to the following<br><br>restrictions:<br><br>1. The origin of this software must not be misrepresented,<br><br>you must not claim that you wrote the original software.<br><br>If you use this software in a product, an acknowledgment<br><br>in the product documentation would be appreciated but is<br><br>not required.<br><br>2. Altered source versions must be plainly marked as such, and<br><br>must not be misrepresented as being the original software.<br><br>3. This notice may not be removed or altered from any source<br><br>distribution.<br><br>Updates:<br><br>Sep 25, 1998 V1.10 Added RasGetIPAddress and RasGetProjectionInfoA. Thanks to<br><br>Jan Tomasek &lt;xtomasej@fel.cvut.cz&gt; for his help.<br><br><br><br>* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br><br>unit Ras;<br><br>interface<br><br>uses<br><br>Windows, SysUtils;<br><br>{$DEFINE WINVER400}<br><br>const<br><br>RasUnitVersion = 110;<br><br>CopyRight : String = ' RasUnit (c) 97-98 F. Piette V1.10 ';<br><br>rasapi32 = 'rasapi32.dll';<br><br>UNLEN = 256; // Maximum user name length<br><br>PWLEN = 256; // Maximum password length<br><br>CNLEN = 15; // Computer name length<br><br>DNLEN = CNLEN; // Maximum domain name length<br><br>RAS_MaxDeviceType = 16;<br><br>RAS_MaxPhoneNumber = 128;<br><br>RAS_MaxIpAddress = 15;<br><br>RAS_MaxIpxAddress = 21;<br><br>{$IFDEF WINVER400}<br><br>RAS_MaxEntryName = 256;<br><br>RAS_MaxDeviceName = 128;<br><br>RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;<br><br>{$ELSE}<br><br>RAS_MaxEntryName = 20;<br><br>RAS_MaxDeviceName = 32;<br><br>RAS_MaxCallbackNumber = 48;<br><br>{$ENDIF}<br><br>RAS_MaxAreaCode = 10;<br><br>RAS_MaxPadType = 32;<br><br>RAS_MaxX25Address = 200;<br><br>RAS_MaxFacilities = 200;<br><br>RAS_MaxUserData = 200;<br><br>RASCS_OpenPort = 0;<br><br>RASCS_PortOpened = 1;<br><br>RASCS_ConnectDevice = 2;<br><br>RASCS_DeviceConnected = 3;<br><br>RASCS_AllDevicesConnected = 4;<br><br>RASCS_Authenticate = 5;<br><br>RASCS_AuthNotify = 6;<br><br>RASCS_AuthRetry = 7;<br><br>RASCS_AuthCallback = 8;<br><br>RASCS_AuthChangePassword = 9;<br><br>RASCS_AuthProject = 10;<br><br>RASCS_AuthLinkSpeed = 11;<br><br>RASCS_AuthAck = 12;<br><br>RASCS_ReAuthenticate = 13;<br><br>RASCS_Authenticated = 14;<br><br>RASCS_PrepareForCallback = 15;<br><br>RASCS_WaitForModemReset = 16;<br><br>RASCS_WaitForCallback = 17;<br><br>RASCS_Projected = 18;<br><br>{$IFDEF WINVER400}<br><br>RASCS_StartAuthentication = 19;<br><br>RASCS_CallbackComplete = 20;<br><br>RASCS_LogonNetwork = 21;<br><br>{$ENDIF}<br><br>RASCS_SubEntryConnected = 22;<br><br>RASCS_SubEntryDisconnected= 23;<br><br>RASCS_PAUSED = $1000;<br><br>RASCS_Interactive = RASCS_PAUSED;<br><br>RASCS_RetryAuthentication = (RASCS_PAUSED + 1);<br><br>RASCS_CallbackSetByCaller = (RASCS_PAUSED + 2);<br><br>RASCS_PasswordExpired = (RASCS_PAUSED + 3);<br><br>RASCS_DONE = $2000;<br><br>RASCS_Connected = RASCS_DONE;<br><br>RASCS_Disconnected = (RASCS_DONE + 1);<br><br>// If using RasDial message notifications, get the notification message code<br><br>// by passing this string to the RegisterWindowMessageA() API.<br><br>// WM_RASDIALEVENT is used only if a unique message cannot be registered.<br><br>RASDIALEVENT = 'RasDialEvent';<br><br>WM_RASDIALEVENT = $CCCD;<br><br>// TRASPROJECTION<br><br>RASP_Amb = $10000;<br><br>RASP_PppNbf = $0803F;<br><br>RASP_PppIpx = $0802B;<br><br>RASP_PppIp = $08021;<br><br>RASP_Slip = $20000;<br><br>type<br><br>THRASCONN = THandle;<br><br>PHRASCONN = ^THRASCONN;<br><br>TRASCONNSTATE = DWORD;<br><br>PDWORD = ^DWORD;<br><br>PBOOL = ^BOOL;<br><br>TRASDIALPARAMS = packed record<br><br>dwSize : DWORD;<br><br>szEntryName : array [0..RAS_MaxEntryName] of Char;<br><br>szPhoneNumber : array [0..RAS_MaxPhoneNumber] of Char;<br><br>szCallbackNumber : array [0..RAS_MaxCallbackNumber] of Char;<br><br>szUserName : array [0..UNLEN] of Char;<br><br>szPassword : array [0..PWLEN] of Char;<br><br>szDomain : array [0..DNLEN] of Char;<br><br>{$IFDEF WINVER401}<br><br>dwSubEntry : DWORD;<br><br>dwCallbackId : DWORD;<br><br>{$ENDIF}<br><br>szPadding : array [0..2] of Char;<br><br>end;<br><br>PRASDIALPARAMS = ^TRASDIALPARAMS;<br><br>TRASDIALEXTENSIONS = packed record<br><br>dwSize : DWORD;<br><br>dwfOptions : DWORD;<br><br>hwndParent : HWND;<br><br>reserved : DWORD;<br><br>end;<br><br>PRASDIALEXTENSIONS = ^TRASDIALEXTENSIONS;<br><br>TRASCONNSTATUS = packed record<br><br>dwSize : DWORD;<br><br>RasConnState : TRASCONNSTATE;<br><br>dwError : DWORD;<br><br>szDeviceType : array [0..RAS_MaxDeviceType] of char;<br><br>szDeviceName : array [0..RAS_MaxDeviceName] of char;<br><br>szPadding : array [0..1] of Char;<br><br>end;<br><br>PRASCONNSTATUS = ^TRASCONNSTATUS;<br><br>TRASCONN = packed record<br><br>dwSize : DWORD;<br><br>hRasConn : THRASCONN;<br><br>szEntryName : array [0..RAS_MaxEntryName] of char;<br><br>{$IFDEF WINVER400}<br><br>szDeviceType : array [0..RAS_MaxDeviceType] of char;<br><br>szDeviceName : array [0..RAS_MaxDeviceName] of char;<br><br>{$ENDIF}<br><br>szPadding : array [0..0] of Char;<br><br>end;<br><br>PRASCONN = ^TRASCONN;<br><br>TRASENTRYNAME = packed record<br><br>dwSize : DWORD;<br><br>szEntryName : array [0..RAS_MaxEntryName] of char;<br><br>szPadding : array [0..2] of Char;<br><br>end;<br><br>PRASENTRYNAME = ^TRASENTRYNAME;<br><br>TRASENTRYDLG = packed record<br><br>dwSize : DWORD;<br><br>hWndOwner : HWND;<br><br>dwFlags : DWORD;<br><br>xDlg : LongInt;<br><br>yDlg : LongInt;<br><br>szEntry : array [0..RAS_MaxEntryName] of char;<br><br>dwError : DWORD;<br><br>Reserved : DWORD;<br><br>Reserved2 : DWORD;<br><br>szPadding : array [0..2] of Char;<br><br>end;<br><br>PRASENTRYDLG = ^TRASENTRYDLG;<br><br>TRASPROJECTION = integer;<br><br>TRASPPPIP = record<br><br>dwSize : DWORD;<br><br>dwError : DWORD;<br><br>szIpAddress : array [0..RAS_MaxIpAddress] of char;<br><br>end;<br><br>&amp;#65377;&amp;#65377;<br><br>function RasDialA(RasDialExtensions: PRASDIALEXTENSIONS;<br><br>PhoneBook : PChar;<br><br>RasDialParams : PRASDIALPARAMS;<br><br>NotifierType : DWORD;<br><br>Notifier : Pointer;<br><br>RasConn : PHRASCONN<br><br>): DWORD; stdcall;<br><br>function RasGetErrorStringA(<br><br>uErrorValue : DWORD; // error to get string for<br><br>szErrorString : PChar; // buffer to hold error string<br><br>cBufSize : DWORD // size, in characters, of buffer<br><br>): DWORD; stdcall;<br><br>function RasHangupA(RasConn: THRASCONN): DWORD; stdcall;<br><br>function RasConnectionStateToString(nState : Integer) : String;<br><br>function RasGetConnectStatusA(<br><br>hRasConn: THRASCONN; // handle to RAS connection of interest<br><br>lpRasConnStatus : PRASCONNSTATUS // buffer to receive status data<br><br>): DWORD; stdcall;<br><br>function RasEnumConnectionsA(<br><br>pRasConn : PRASCONN; // buffer to receive connections data<br><br>pCB : PDWORD; // size in bytes of buffer<br><br>pcConnections : PDWORD // number of connections written to buffer<br><br>) : DWORD; stdcall<br><br>function RasEnumEntriesA(<br><br>Reserved : Pointer; // reserved, must be NIL<br><br>szPhonebook : PChar; // full path and filename of phonebook file<br><br>lpRasEntryName : PRASENTRYNAME; // buffer to receive entries<br><br>lpcb : PDWORD; // size in bytes of buffer<br><br>lpcEntries : PDWORD // number of entries written to buffer<br><br>) : DWORD; stdcall;<br><br>function RasGetEntryDialParamsA(<br><br>lpszPhonebook : PChar; // pointer to the full path and filename of the phonebook file<br><br>lprasdialparams : PRASDIALPARAMS; // pointer to a structure that receives the connection parameters<br><br>lpfPassword : PBOOL // indicates whether the user's password was retrieved<br><br>) : DWORD; stdcall;<br><br>function RasEditPhonebookEntryA(<br><br>hWndParent : HWND; // handle to the parent window of the dialog box<br><br>lpszPhonebook : PChar; // pointer to the full path and filename of the phonebook file<br><br>lpszEntryName : PChar // pointer to the phonebook entry name<br><br>) : DWORD; stdcall;<br><br>//function RasEntryDlgA(<br><br>// lpszPhonebook : PChar; // pointer to the full path and filename of the phone-book file<br><br>// lpszEntry : PChar; // pointer to the name of the phone-book entry to edit, copy, or create<br><br>// lpInfo : PRASENTRYDLG // pointer to a structure that contains additional parameters<br><br>// ) : DWORD; stdcall;<br><br>function RasCreatePhonebookEntryA(<br><br>hWndParent : HWND; // handle to the parent window of the dialog box<br><br>lpszPhonebook : PChar // pointer to the full path and filename of the phonebook file<br><br>) : DWORD; stdcall;<br><br>function RasGetProjectionInfoA(<br><br>hRasConn : THRASCONN; // handle that specifies remote access connection of interest<br><br>RasProjection : TRASPROJECTION; // specifies type of projection information to obtain<br><br>lpProjection : Pointer; // points to buffer that receives projection information<br><br>lpcb : PDWORD // points to variable that specifies buffer size<br><br>) : DWORD; stdcall;<br><br>function RasGetIPAddress: string;<br><br>implementation<br><br>&amp;#65377;&amp;#65377;<br><br>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br><br>function RasConnectionStateToString(nState : Integer) : String;<br><br>begin<br><br>case nState of<br><br>RASCS_OpenPort: Result := 'Opening Port';<br><br>RASCS_PortOpened: Result := 'Port Opened';<br><br>RASCS_ConnectDevice: Result := 'Connecting Device';<br><br>RASCS_DeviceConnected: Result := 'Device Connected';<br><br>RASCS_AllDevicesConnected: Result := 'All Devices Connected';<br><br>RASCS_Authenticate: Result := 'Starting Authentication';<br><br>RASCS_AuthNotify: Result := 'Authentication Notify';<br><br>RASCS_AuthRetry: Result := 'Authentication Retry';<br><br>RASCS_AuthCallback: Result := 'Callback Requested';<br><br>RASCS_AuthChangePassword: Result := 'Change Password Requested';<br><br>RASCS_AuthProject: Result := 'Projection Phase Started';<br><br>RASCS_AuthLinkSpeed: Result := 'Link Speed Calculation';<br><br>RASCS_AuthAck: Result := 'Authentication Acknowledged';<br><br>RASCS_ReAuthenticate: Result := 'Reauthentication Started';<br><br>RASCS_Authenticated: Result := 'Authenticated';<br><br>RASCS_PrepareForCallback: Result := 'Preparation For Callback';<br><br>RASCS_WaitForModemReset: Result := 'Waiting For Modem Reset';<br><br>RASCS_WaitForCallback: Result := 'Waiting For Callback';<br><br>RASCS_Projected: Result := 'Projected';<br><br>{$IFDEF WINVER400}<br><br>RASCS_StartAuthentication: Result := 'Start Authentication';<br><br>RASCS_CallbackComplete: Result := 'Callback Complete';<br><br>RASCS_LogonNetwork: Result := 'Logon Network';<br><br>{$ENDIF}<br><br>RASCS_SubEntryConnected: Result := '';<br><br>RASCS_SubEntryDisconnected: Result := '';<br><br>RASCS_Interactive: Result := 'Interactive';<br><br>RASCS_RetryAuthentication: Result := 'Retry Authentication';<br><br>RASCS_CallbackSetByCaller: Result := 'Callback Set By Caller';<br><br>RASCS_PasswordExpired: Result := 'Password Expired';<br><br>RASCS_Connected: Result := 'Connected';<br><br>RASCS_Disconnected: Result := 'Disconnected';<br><br>else<br><br>Result := 'Connection state #' + IntToStr(nState);<br><br>end;<br><br>end;<br><br>&amp;#65377;&amp;#65377;<br><br>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br><br>function RasGetIPAddress: string;<br><br>var<br><br>RASConns : TRasConn;<br><br>dwSize : DWORD;<br><br>dwCount : DWORD;<br><br>RASpppIP : TRASPPPIP;<br><br>begin<br><br>Result := '';<br><br>RASConns.dwSize := SizeOf(TRASConn);<br><br>RASpppIP.dwSize := SizeOf(RASpppIP);<br><br>dwSize := SizeOf(RASConns);<br><br>if RASEnumConnectionsA(@RASConns, @dwSize, @dwCount) = 0 then begin<br><br>if dwCount &gt; 0 then begin<br><br>dwSize := SizeOf(RASpppIP);<br><br>RASpppIP.dwSize := SizeOf(RASpppIP);<br><br>if RASGetProjectionInfoA(RASConns.hRasConn,<br><br>RASP_PppIp,<br><br>@RasPPPIP,<br><br>@dwSize) = 0 then<br><br>Result := StrPas(RASpppIP.szIPAddress);<br><br>end;<br><br>end;<br><br>end;<br><br>&amp;#65377;&amp;#65377;<br><br>&amp;#65377;&amp;#65377;<br><br>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br><br>function RasDialA; external rasapi32 name 'RasDialA';<br><br>function RasGetErrorStringA; external rasapi32 name 'RasGetErrorStringA';<br><br>function RasHangUpA; external rasapi32 name 'RasHangUpA';<br><br>function RasGetConnectStatusA; external rasapi32 name 'RasGetConnectStatusA';<br><br>function RasEnumConnectionsA; external rasapi32 name 'RasEnumConnectionsA';<br><br>function RasEnumEntriesA; external rasapi32 name 'RasEnumEntriesA';<br><br>function RasGetEntryDialParamsA; external rasapi32 name 'RasGetEntryDialParamsA';<br><br>function RasEditPhonebookEntryA; external rasapi32 name 'RasEditPhonebookEntryA';<br><br>//function RasEntryDlgA; external rasapi32 name 'RasEntryDlgA';<br><br>function RasCreatePhonebookEntryA; external rasapi32 name 'RasCreatePhonebookEntryA';<br><br>function RasGetProjectionInfoA; external rasapi32 name 'RasGetProjectionInfoA';<br><br>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br><br>end.<br><br>{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}<br>
 
后退
顶部