View previous topic :: View next topic |
Author |
Message |
Ezneh
Joined: 08 Feb 2010 Posts: 2 Location: Belgium
|
Posted: Mon Aug 30, 2010 12:59 am Post subject: Winapi - Error |
|
|
Hi, hope there's someone here who can help me with this problem
I want to use some functions like "GetSystemDirectory" and something like that but I get error when I use them.
Here a sample code :
import win32.windows;
int main(char[][] args)
{
LPSTR test = null;
GetSystemDirectoryA(test,256U);
return 0;
}
When I run it I get "objet.Error - Access violation".
What am I doing wrong or what is wrong with the binding ?
(Information : I'm using D2 [dmd2.048] with latest phobos library and latest win32 binding)
EDIT : Ok I found what I was doing wrong but it seems that there's another problem again :
import std.stdio;
import std.string;
import win32.windows;
int main(char[][] args)
{
LPSTR test = cast(char*)"";
try
{
GetSystemDirectoryA(test,500U);
printf("%s", test);
}
catch(Object o)
writeln(o.toString);
return 0;
}
Which prints "indows\system32"
Why I don't have "C:\Windows\system32" ? |
|
Back to top |
|
|
Ezneh
Joined: 08 Feb 2010 Posts: 2 Location: Belgium
|
Posted: Mon Aug 30, 2010 1:40 am Post subject: |
|
|
Ok, I tried with writeln and it's ok now
So, this code works well now :
import std.stdio;
import std.string;
import std.conv;
import win32.windows;
int main(char[][] args)
{
LPSTR test = cast(char*)"";
try
{
uint i = GetSystemDirectoryA(test,100U);
writeln(to!string(test));
}
catch(Object o)
writeln(o.toString);
return 0;
} |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|