You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

axtens

Trainee

  • "axtens" is male
  • "axtens" started this thread

Posts: 37

Date of registration: Mar 16th 2009

Location: Perth, WA, Australia

Occupation: Software/Test Engineer

Hobbies: be a husband and a dad, play ukulele, sing

  • Send private message

1

Saturday, October 3rd 2009, 5:44pm

Passing Long Pointer to String in *W Win32 API calls

In the following code (project attached) I'm trying to call GetLogicalDriveStringsW Win32 API function which expects to receive a long pointer to the string, rather than the string as would be the case with GetLogicalDriveStringsA (the ANSI version.) How do I achieve this? In VB6 I'd use StrPtr() but that doesn't appear to be available.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Private WinAPI Function GetLogicalDriveStrings Lib "kernel32.dll" Alias "GetLogicalDriveStringsW" ( _ 
	 ByVal nBufferLength As Long, _ 
	 ByVal lpBuffer As String) As Long

Public Sub main(ByJava args() As String)
   Dim myArgs() As String
   myArgs = args
   ' [Your Source]
   Dim s As String
   Dim l As Long
   l = GetLogicalDriveStrings(0,s)
   out.print(l)
   s = String$(l+1," ")
   l = GetLogicalDriveStrings(l+1,s)
   Dim i As Integer
   For i = 1 To l
  	out.print Asc(Mid$(s,i,1))
   Next
End Sub


Kind regards,
Bruce.
axtens has attached the following file:
  • GLDS.zip (3.39 kB - 431 times downloaded - latest: Apr 7th 2024, 4:53am)

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

2

Saturday, October 3rd 2009, 8:35pm

Hi Bruce,

If you had a Visual Basic that could be used with the same code and with the same assembly on EVERY platform like, Linux, MacOS, Windows...

wouldn't you say better goodbye to good old well known API-dll-hell under Windows?

Try to give it a chance ;)

Possible very easy solution to your drive letters problem without WinAPI:

Jabaco Source

1
2
3
4
5
6
Dim roots() As java#io#File
   roots = java#io#File.listRoots
   Dim i As Integer
   For i = 0 To Ubound(roots)
      Debug.Print roots(i)
   Next


greetings

OlimilO



P.S.: as already said on different other postings (dig the forum), Jabaco until now is not able of mashalling ByRef-Out parameters.

Stefan Schnell has a very cool solution (dig the forum for Varptr.dll) that could be helpful for other problems that are not covered by the Java-Framework. I hope that sometimes he maybe finds the time to implement a function where strings could be read one by one char via function return values.

Rate this thread
WoltLab Burning Board