?
Solved

Problem in GetWindowsDirectory

Posted on 2001-06-30
2
Medium Priority
?
618 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 60 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 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