StrPtr in .NET

Hi, I am making an API call NetFileEnum in an application that I am writing in C#. I have sample caode of this function been called in vb6. The problem I am having is that in vb6 the StrPtr function is called on a variable and then passed to the API. .NET however does not support this function. Can someone please help me with a way of getting around this or perhaps let me know where I can get sample c# code of the NetFileEnum call.

Thanks in advance.

[458 byte] By [GBez] at [2007-12-16]
# 1

K, in reply to the above, I managed to find some code that does the same in c# as the StrPtr function in vb6. After implementing it in my function however, it still did not work. Can anybody see any problem in my code? Here is the vb code:

dwServer = StrPtr(sServer)

success = NetFileEnum(dwServer, _
0&, _
0&, _
3, _
bufptr, _
MAX_PREFERRED_LENGTH, _
dwEntriesread, _
dwTotalentries, _
dwResumehandle)


and here is my corresponding code:

GCHandle MyGC = GCHandle.Alloc(serv, GCHandleType.Pinned);

IntPtr server = MyGC.AddrOfPinnedObject();

string strServer = server.ToString();

//get list of open files

int dwStatus = NetFileEnum(strServer , null, null, 3, ref pBuffer, MAX_PREFERRED_LENGTH, out dwReadEntries, out dwTotalEntries, IntPtr.Zero );

GBez at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 2
Found that if I pass through serv instead of strServer it works.
GBez at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 3
Hey, do you still have the code for NetFileEnum. Am looking for a .net implementation...
AndrewVos at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified