Net Use - API/.Decls problems

BlitzPlus Forums/BlitzPlus Programming/Net Use - API/.Decls problems

Sin of Nature(Posted 2003) [#1]
--------------------------------------------------------------------------------
Hi,
Using Blitz+ neat .decls capabilities and trying to convert some of my old Visual Basic code into Blitz. I'm having trouble trying to work out how to get some of the parameters to work. For example, Blitz+ does not have Long's, only Int's. How do strip NULL's from the end of strings... etc.
The code below is a simple example of calling some api calls from within the MPR.DLL. It trying to map a drive to a machine.

Under Visual Basic, some of the constants had &H1 which I think means Hex value 1. Under blitz, I couldnt see away of using hex numbers, so I simply converted them to decimal. Will that work?

The 2nd think I've done is used INT's instead of LONG's. I'm not sure how many Bytes that Blitz's INT's use compared with the number of bytes used in Visual Basics LONG's. I also need a Strip Nulls routine from the UserID string.

Pretty new to this .decls thing.

[CODE]
Const RESOURCETYPE_ANY = 0 ; &H0
Const RESOURCETYPE_DISK = 1 ; &H1
Const RESOURCETYPE_PRINT = 2 ; &H2
Const RESOURCETYPE_UNKNOWN = 65535 ; &HFFFF
Const CONNECT_UPDATE_PROFILE = 1
Const NO_ERROR = 0
Const ERROR_ACCESS_DENIED = 5
Const ERROR_ALREADY_ASSIGNED = 85
Const ERROR_BAD_DEV_TYPE = 66
Const ERROR_BAD_DEVICE = 1200
Const ERROR_BAD_NET_NAME = 67
Const ERROR_BAD_PROFILE = 1206
Const ERROR_BAD_PROVIDER = 1204
Const ERROR_BUSY = 170
Const ERROR_CANNOT_OPEN_PROFILE = 1205
Const ERROR_DEVICE_ALREADY_REMEMBERED = 1202
Const ERROR_DEVICE_IN_USE = 2404
Const ERROR_EXTENDED_ERROR = 1208
Const ERROR_INVALID_PASSWORD = 86
Const ERROR_NO_NET_OR_BAD_PATH = 1203
Const ERROR_NO_NETWORK = 1222
Const ERROR_NOT_CONNECTED = 2250
Const ERROR_OPEN_FILES = 2401
;Define miscellaneous variables

Const ERROR_INVALID_ADDRESS = 487
Const ERROR_INVALID_PARAMETER = 87
Const ERROR_MORE_DATA = 234
Const ERROR_UNEXP_NET_ERR = 59
Const ERROR_NOT_SUPPORTED = 50
Const ERROR_NOT_ENOUGH_MEMORY = 8

Type NETRESOURCE
Field dwScope ; Long
Field dwType ; Long
Field dwDisplayType ; Long
Field dwUsage ; Long
Field lpLocalName$ ; String
Field lpRemoteName$ ; String
Field lpComment$ ; String
Field lpProvider$ ; String
End Type


Global rc
Global lCxnType
Global netAddCxn.NETRESOURCE = New NETRESOURCE
Global varPersistent = 0
Global sPassword = "", sUserID="administrator"


lCxnType = RESOURCETYPE_DISK

netAddCxn\dwType = RESOURCETYPE_DISK
netAddCxn\lpLocalName = "R:" ;sLocalDevice
netAddCxn\lpRemoteName = "\\MyMachine\c$" ;sShareName
netAddCxn\lpProvider = Chr(0)


rc = api_WNetAddConnection2(netAddCxn, sPassword, sUserID, varPersistent)

DebugLog rc

WaitKey()

[/CODE]

Anyone help?


Beaker(Posted 2003) [#2]
Some pointers:
use $ for hex numbers in Blitz - eg. $F7

Blitz Ints use 4 bytes (as do Floats).


dynaman(Posted 2003) [#3]
also - visual basic create dll files will not work with blitz. Something to do with VB making activeX .dll files instead of the kind blitz can use.

Hopefully someone who actually knows the difference will post so you don't have to rely on my rambling.


Sin of Nature(Posted 2003) [#4]
The calls are not from a VB DLL. Its a standard windows API call (ie. windows DLL's).

You are right about VB's DLL's though, my mate had same problem calling them via C++.

Sin


augGa(Posted 2003) [#5]
u are all correct regarding using DLL crated with 'out-of the box" vb6.0..however.. some bright folks at WWW.vbAdvance.com have solved the problem.. YOU CAN USE Visual Basic DLL's with Blitz3d..


semar(Posted 2003) [#6]
@Kurtz,
did you check if VBAdvance could really give to VB6 the capability of writing a DLL-Blitz compatible ?

Sergio.


augGa(Posted 2003) [#7]
Yes...I have it working ...I am still trying to get forms working ... everything else (strings,numbers) work fine for both VB subs and functions.. my app uses INI files...I am using a vb6 written DLL with 6 functions to rd/wrt INI files..VBAdvance is FREE TO TRY.. it is quite easy...If I could get some of you 'really bright' folks using it you would figure out some neat stuff to do...email me and I will send you the code (vb6/Blitz) that I used to test vbadvance (short)


semar(Posted 2003) [#8]
@Kurtz,
you've got mail at the address specified in your profile.

Sergio.