` Printed Icetips Article

Icetips Article



Windows API: Passing null terminated arrays to PathFindOnPath
2003-08-31 -- John E. Christ III
 
Newsgroups: softvelocity.products.c55ee

One more time...  A line that wasn't supposed to be there (PathPtr[1] = 0)
somehow crept in.

Maarten,

> > >How do I define a null-terminated array (ppsz) for an API call?

For the non-UNICODE version

MODULE('Win32.lib')
PathFindOnPath(*CSTRING, LONG), LONG, RAW, PASCAL, DLL,|
    NAME('PathFindOnPathA')
END

Data:

Filename CSTRING(256)
Paths    CSTRING(256), DIM(100)
PathPtr  LONG, DIM(100)

Code:

Filename = 'MyApp.app'
Paths[1] = 'c:\MyDir1'
PathPtr[1] = ADDRESS(Paths[1])
Paths[2] = 'c:\MyDir2'
PathPtr[2] = ADDRESS(Paths[2])
PathPtr[3] = 0 ! Null terminate the array of pointers
X# = PathFindOnPath(Filename, ADDRESS(PathPtr))
IF X#
    MESSAGE('Found it!')
ELSE
    MESSAGE('Didn''t find it!')
END

John



Printed May 5, 2024, 9:42 am
This article has been viewed/printed 35116 times.
Google search has resulted in 151 hits on this article since January 25, 2004.