FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Winapi - Error

 
Post new topic   Reply to topic     Forum Index -> Bindings
View previous topic :: View next topic  
Author Message
Ezneh



Joined: 08 Feb 2010
Posts: 2
Location: Belgium

PostPosted: Mon Aug 30, 2010 12:59 am    Post subject: Winapi - Error Reply with quote

Hi, hope there's someone here who can help me with this problem Smile


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 Sad :

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
View user's profile Send private message
Ezneh



Joined: 08 Feb 2010
Posts: 2
Location: Belgium

PostPosted: Mon Aug 30, 2010 1:40 am    Post subject: Reply with quote

Ok, I tried with writeln and it's ok now Smile

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Bindings All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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