Solved

Problem in GetWindowsDirectory

Posted on 2001-06-30
2
614 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
[X]
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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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…
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 this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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