Solved

Problem in GetWindowsDirectory

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now