Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem in GetWindowsDirectory

Posted on 2001-06-30
2
609 Views
Last Modified: 2006-11-17
Hi
  I'm writting a programm in Delphi 5.
I want to get windows directory ,so i use GetWindowsDirectory API.
When I run it in Delphi there is no problem ,but
When i run it alone it doesn't give me the directory.
What's the matter?
0
Comment
Question by:s_arb
2 Comments
 
LVL 13

Accepted Solution

by:
Epsylon earned 20 total points
ID: 6240595
You probably did not allocate memory for the buffer.
This should work:

function GetWinDir: String;
var a: array[0..MAX_PATH] of Char;
begin
  GetWindowsDirectory(a, sizeof(a));
  Result := a;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(GetWinDir);
end;
0
 

Author Comment

by:s_arb
ID: 6242253
Thank you
My problem is solved.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question