Re: DhcpRequestParams from dhcpcsvc.dll
- From: cowprod <cowprod@xxxxxxxxx>
- Date: Mon, 03 Sep 2007 14:36:41 -0700
Problem is solved for me, I took the rfc and I deal with the dhcp in
udp...no compatibility issue with Vista, xp sp2...
If some on need help do not hesitate to ask...
Personaly I think that giving fonctional exemples is the best way to
help the others.
How to learn to pass the arguments if you don't help to have the right
declaration...
thank you for your help
Emmanuel
On 2 sep, 10:31, "Mark Yudkin" <DoNotContac...@xxxxxxxxxxxxxx> wrote:
I am quite willing to give you pointers, but I will not do your homework for
you. You need to learn and understand the fundamentals of using Windows APIs
and so far you have not shown any interest in actually reading the basic
"how to" documentation (and I've been quite explicit about what you should
be reading). If you don't learn the principles, you'll just get stuck next
time you have the same issues and these will arise whenever you try to use
the Windows API.
"cowprod" <cowp...@xxxxxxxxx> wrote in message
news:1188161875.617687.324810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
thank you for trying to help me but...
if you know what is wrong...why don't you give me the good way to
declare, calling and passing ? if I post the original .h declaration
it is because I do think that my own vb declaration is wrong, like I
wrote it in my last message.
thank by advance
Emmanuel
On Aug 26, 10:09 am, "Mark Yudkin" <DoNotContac...@xxxxxxxxxxxxxx>
wrote:
You're still not dealing with the Unicode strings properly - both the
declarations and the calling code are wrong. You cannot simply convert a
string to Unicode with StrConv and pass that as a string. Review KB145727
and KB199824, as well as the VB6 documentation.
"cowprod" <cowp...@xxxxxxxxx> wrote in message
news:1187781771.559094.194950@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ok thank you for your help, I'm coming back on this task.
here is the (cleaned) source code:
-----------------------------------------------------------------------
Option Explicit
Public Type DHCPAPI_PARAMS
flags As Long
optionid As Long
isvendor As Boolean
data As Byte
nbytes As Long
End Type
Public Type DHCPCAPI_CLASSID
flags As Long
data As Byte
nbytes As Long
End Type
Public Type DHCPCAPI_PARAMS_ARRAY
nParams As Long
params As DHCPAPI_PARAMS
End Type
Public Const OPTION_HOST_NAME = 12
Public Const DHCPCAPI_REQUEST_SYNCHRONOUS = &H2
Declare Function DhcpRequestParams Lib "dhcpcsvc.dll" ( _
ByVal flags As Long, _
ByVal Reserved As Long, _
ByVal AdapterName As String, _
ByRef ClassId As DHCPCAPI_CLASSID, _
ByRef sendParams As DHCPCAPI_PARAMS_ARRAY, _
ByRef RecdParams As DHCPCAPI_PARAMS_ARRAY, _
ByVal buffer As String, _
ByRef pSize As Long, _
ByVal RequestIdStr As String) As Long
Sub Main()
Dim dClsId As DHCPCAPI_CLASSID
Dim recParams As DHCPAPI_PARAMS
Dim sendParams As DHCPAPI_PARAMS
Dim sendParamsArray As DHCPCAPI_PARAMS_ARRAY
Dim recParamsArray As DHCPCAPI_PARAMS_ARRAY
Dim dNot As Long
Dim sBuffer As String
Dim sMyNic As String
'my lan card name , is-it wrong to pass { and }? this does not
change the result for the moment :)
sMyNic = "{45691A3A-8A5D-4E6E-A5A7-A018BDD69EDE}"
'in c(++) examples found null is passed but how to pass null ?
With dClsId
.data = 0
.flags = 0
.nbytes = 0
End With
'sendParamsArray definition
'in c(++) examples null is passed but how to pass null for param ?
With sendParams
.flags = 0
.optionid = 0
.isvendor = False
.data = 0
.nbytes = 0
End With
'in c(++) examples null is passed but how to pass null for param ?
With sendParamsArray
.nParams = 0
.params = sendParams
End With
'recParamsArry definition
With recParams
.flags = 0
.optionid = OPTION_HOST_NAME
.isvendor = vbFalse
.data = 0
.nbytes = 0
End With
With recParamsArray
.nParams = 1
.params = recParams
End With
'calling DhcpRequestParams
dNot = DhcpRequestParams( _
DHCPCAPI_REQUEST_SYNCHRONOUS, _
0, _
StrConv(sMyNic, vbUnicode), _
dClsId, _
sendParamsArray, _
recParamsArray, _
sBuffer, _
1000, _
vbNullString)
'alway return 87 wrong params
MsgBox Trim("" & dNot)
End Sub
----------------------------------------------------------------------------------------------------------------------------------------------
I'm still nor sur of DhcpRequestParams declaration, there is
diffrence with the header file:
DhcpRequestParams( // request
parameters of client
IN DWORD Flags, // must be
DHCPCAPI_REQUEST_SYNCHRONOUS
IN LPVOID Reserved, // this parameter is
reserved
IN LPWSTR AdapterName, // adapter name to
request for
IN LPDHCPCAPI_CLASSID ClassId, // reserved must be
NULL
IN DHCPCAPI_PARAMS_ARRAY SendParams, // parameters to
send.
IN OUT DHCPCAPI_PARAMS_ARRAY RecdParams, // parameters that
are to be requested..
IN LPBYTE Buffer, // a buffer to hold
data for RecdParams
IN OUT LPDWORD pSize, // i/p: size of
above in BYTES, o/p required bytes..
IN LPWSTR RequestIdStr // needed for
persistent requests
); // returns ERROR_MORE_DATA if o/p buffer is of insufficient size,
and fills in reqd size in # of bytes
I still have the 87 return value (same result with vista, 2003 sp1 so
it must not be the xp Sp2 problem - KB885270)
Any advice/solution is welcome
Sincerely
On 6 août, 15:19, "Mark Yudkin" <DoNotContac...@xxxxxxxxxxxxxx> wrote:
Your first post said "but I didn't find any thing more than the
following
declaration (whithout types definitions)", so I pointed you to the
documentation to answer that question.
You posted an incorect VB6 declaration, but given the link to the
documentation that's simple to resolve - e.g, set Reserved to a byval
long,
fix RecdParams (it's the same as SendParams), sort out Buffer, check
your
declarations of the UDTs (you failed to post these).
Perhaps you should do some basic coding and come back if you hit a
specific
issue. Remember that you have LPWSTR parameters, so you have to pass
Unicode
strings.
If you need help with these topics, review the VB6 documentation on
calling
APIs.
"cowprod" <cowp...@xxxxxxxxx> wrote in message
news:1186385534.988974.135560@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
thank you for your answer, but like I wrote I already know the
declarations and arguments types but I don't find the way to call the
function successfully with VB6, I'm looking for an exemple (in vb6).
Thank you- Masquer le texte des messages précédents -
- Afficher le texte des messages précédents -- Hide quoted text -
- Show quoted text -- Masquer le texte des messages précédents -
- Afficher le texte des messages précédents -
.
- References:
- Re: DhcpRequestParams from dhcpcsvc.dll
- From: Mark Yudkin
- Re: DhcpRequestParams from dhcpcsvc.dll
- Prev by Date: Re: Bad Dll calling convention
- Next by Date: Sleep function prevents label visibility
- Previous by thread: Re: DhcpRequestParams from dhcpcsvc.dll
- Next by thread: Re: Bad Dll calling convention
- Index(es):
Relevant Pages
|