Solved

Problem in GetWindowsDirectory

Posted on 2001-06-30
2
610 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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