Michael,
An IntPtr is a value type, and you need to pass IntPtr.Zero to
represent
a null pointer.
Also, why not just call the static CreateDirectory method on the
Directory class in the System.IO namespace?
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
OK thanks again, it helped but now I have another problem:
I put this declaration inside the class:
[DllImport("kernel32.dll")]
static extern bool CreateDirectory(string lpPathName,
IntPtr lpSecurityAttributes);
static bool B;
and when I use this
B= CreateDirectory("Directory",null);
it says: The best overloeaded method match for CreateDirectory(string,
System.IntPtr has some invalid arguments
and Argument '2':cannot convert from < null> to System.IntPtr'
I put null since I have no idea what this second argument means and how
to
create a IntPtr, and what is it anyway?
Thanks again
:
Michael,
Where are you placing the declaration? Is it outside of a class?
You
need to place the declaration inside of a class declaration in order
for
it
to compile correctly.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Thanks.
But very function I use I get the compile time error:
Invalid expression term '['
; expected
Invalid expression temr ']'
and I see a red underline under the "[DllImport("kernel32.dll")]
for example when I try to use the api function CreateDirectory.
What's missing?
PS: I have included the line "using System.Runtime.InteropServices;"
if
that
helps
PS2:the structure of the api function is:
[DllImport("kernel32.dll")]
static extern bool CreateDirectory(string lpPathName,
IntPtr lpSecurityAttributes);
:
In addition to what Nicholas has already said, if you're looking at
how
to
use them from c#,
see:
http://pinvoke.net/
Hello, I wanted to ask what are API functions, how do they differ
from
the
regular functions and how can I use them in C#/visual C#. (
please
give
an
example if you can)
Thanks a lot.