Problem with DHCPEnumSubnetClients

I'm using VB6 and I've a problem with DHCPEnumSubnetClinents API.

Declare Function DhcpEnumSubnetClients Lib "Dhcpsapi" (ByVal ServerIpAddress As String, _
                                                        ByVal SubnetAddress As Long, _
                                                        ByRef  ResumeHandle As Integer, _
                                                        ByRef PreferredMaximum As Integer, _
                                                        ByRef ClientInfo As Integer, _
                                                        ByRef ClientsRead As Integer, _
                                                        ByRef ClientsTotal As Integer) As Integer

The field SubnetAddress is supose to be a Long, but the decimal value for the my Subnet is actualy a double.The subnet address decimal value is 4294967040# wich is a double not a long.
But if I change on the function the SubnetAdress data type to double I receive runtime error 49 'Bad  DLL Calling Convention'.
I've tried to change the field data type to "byVal SubnetAddress as Any" and pass the value as a string but then the function returns no values.
Can somenone help me with this?

Best Regards
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>> wich is a double not a long

Doesn't it work if you just send it as a Long?

0xFFFFFF00 as a signed 32bit number = -256, not 4294967040

JMFCAMPOSAuthor Commented:
Hi Tim.
Ok! Now the error is gone, but the function returns no values.
I used both the values for the SubnetMaskID field but the result is the same: no entries returned by the function.

    vServerIP = ""
    pt = 0
    Rem_Handle = 0
    vSubNetIp=&HFFFFFF00 '
    X = DhcpEnumSubnetClients(vServerIP, &HFFFFFF00, Rem_Handle, 32767, pt, Read_Clients, Total_Clients)
    X = DhcpEnumSubnetClients(vServerIP, 256, Rem_Handle, 32767, pt, Read_Clients, Total_Clients)

Any clue?

Best Regards

should be:

    vSubNetIp = -256

(afaik) :-/
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

JMFCAMPOSAuthor Commented:
I 've tried. The function returns no values with -256.
Hmmm....I'm all out of ideas I'm afraid...hopefully someone else will be able to give you a solution :-(

Sorry I couldn't help...

Good luck!

JMFCAMPOSAuthor Commented:
Hi there.
I've quit the idea of using the API function dhcpenumsubnetclients, it just d'ont works.
So I have to use DHCPCMD.exe.
I execute the following command line in a batch file on a hidden window using Shellexecute:  "dhcpcmd netAddress enumclients DHCPserverAddress > Result.txt".
The file Result.txt contains the list of the DHCP leases.

Thank's anyway for all the help.
Cool!  Really glad you got it sorted out, and sorry I couldn't help more :-(

If you post a question here:  for 0 points, you can get your points back, and this question added to the "Answered Questions" list, as I'm sure it will help someone in the future :-)

Good skills!

And Good luck!!

Closed, 250 points refunded.
Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.