Exception in Delphi 2009 when closing aan pplication that calls these two methods

I am seeing an Exception in Delphi 2009 when closing an application that 
calls these the ListDrives method shown below.

There must be a problem because the excption ocurs at run time in the Delphi 
2009 IDE only.  When the application that uses this is run from the EXE 
there is no exception.  Even Eurekalog does not help find the problem.

Any suggestions?

Thanks

Bill

procedure MultiSzToStrings( const MultiSz: PChar;
  const Strings: Classes.TStrings );
{Splits out individual strings from given 'MultiSz' strings buffer and adds
each string to the given string list. A MultiSz string is a sequence of #0
delimited strings terminated by an extra #0 character. Does nothing if 
string
list or MultiSz buffer are nil.}
var
  p: PChar; // pointer to strings in buffer
begin
  // Do nothing in MultiSz is nil
  if not Assigned( MultiSz ) then
    Exit;
  // Scan thru #0 delimited strings until #0#0 found
  p := MultiSz;
  while p^ <> #0 do
  begin
    // add string to list
    Strings.Add( p );
    // move pointer to start of next string if any
    inc( p, SysUtils.StrLen( p ) + 1 );
  end;
end;

procedure ListDrives( const List: Classes.TStrings );
{Gets list of the system's drive root paths and stores in a given string 
list}
var
  Drives: PChar; // buffer for list of drives
  BufSize: integer; // size of drive buffer
begin
  // Get buffer size and allocate it
  BufSize := Windows.GetLogicalDriveStrings( 0, nil );
  GetMem( Drives, BufSize );
  try
    // Get #0 delimited drives list and convert to string list
    if Windows.GetLogicalDriveStrings( BufSize, Drives ) = 0 then
      //SysUtils.RaiseLastWin32Error;
      SysUtils.RaiseLastOSError;
    MultiSzToStrings( Drives, List );
  finally
    FreeMem( Drives );
  end;
end;
0
Bill
2/21/2009 8:12:52 PM
embarcadero.delphi.win32 2183 articles. 0 followers. Follow

3 Replies
622 Views

Similar Articles

[PageSpeed] 58

Bill,

> I am seeing an Exception in Delphi 2009 when closing an application that 
> calls these the ListDrives method shown below.
> 
> There must be a problem because the excption ocurs at run time in the Delphi 
> 2009 IDE only.  When the application that uses this is run from the EXE 
> there is no exception.  Even Eurekalog does not help find the problem.
> 
> Any suggestions?

Does the fault only occur if you step through ListDrives?

Have you tried commenting-out sections of ListDrives to isolate the root
cause?

- Brian
0
Brian
2/21/2009 10:10:46 PM
"Bill Miller" <@w2m00@frontiernet00.net> escribió en el mensaje de noticias 
news:83942@forums.codegear.com...
>I am seeing an Exception in Delphi 2009 when closing an application that
> calls these the ListDrives method shown below.
>
> There must be a problem because the excption ocurs at run time in the 
> Delphi
> 2009 IDE only.  When the application that uses this is run from the EXE
> there is no exception.  Even Eurekalog does not help find the problem.
>
> Any suggestions?
>
> Thanks
>
> Bill
>
> procedure MultiSzToStrings( const MultiSz: PChar;
>  const Strings: Classes.TStrings );
> {Splits out individual strings from given 'MultiSz' strings buffer and 
> adds
> each string to the given string list. A MultiSz string is a sequence of #0
> delimited strings terminated by an extra #0 character. Does nothing if
> string
> list or MultiSz buffer are nil.}
> var
>  p: PChar; // pointer to strings in buffer
> begin
>  // Do nothing in MultiSz is nil
>  if not Assigned( MultiSz ) then
>    Exit;
>  // Scan thru #0 delimited strings until #0#0 found
>  p := MultiSz;
>  while p^ <> #0 do
>  begin
>    // add string to list
>    Strings.Add( p );
>    // move pointer to start of next string if any
>    inc( p, SysUtils.StrLen( p ) + 1 );
>  end;
> end;
>
> procedure ListDrives( const List: Classes.TStrings );
> {Gets list of the system's drive root paths and stores in a given string
> list}
> var
>  Drives: PChar; // buffer for list of drives
>  BufSize: integer; // size of drive buffer
> begin
>  // Get buffer size and allocate it
>  BufSize := Windows.GetLogicalDriveStrings( 0, nil );
>  GetMem( Drives, BufSize );

GetLogicalDriveStrings returns the length, in characters, not in bytes.
In D2009, sizeof(Char)= 2 so you must allocate BufSize*sizeof(Char) bytes:

   GetMem( Drives, BufSize*sizeof(Char));


>  try
>    // Get #0 delimited drives list and convert to string list
>    if Windows.GetLogicalDriveStrings( BufSize, Drives ) = 0 then
>      //SysUtils.RaiseLastWin32Error;
>      SysUtils.RaiseLastOSError;
>    MultiSzToStrings( Drives, List );
>  finally
>    FreeMem( Drives );
>  end;
> end;
0
Antonio
2/21/2009 11:05:56 PM
Thanks Antonio,

That fixed it.

Regards,

Bill
0
Bill
2/22/2009 4:07:02 PM
Reply:

Similar Artilces:

Delphi 5 To Delphi 2009
I upgraded to Delphi 2009 from D5. The install says I can install Delphi and/or C++. Delphi installed OK but I see nothing of C++. What am I missing or does my upgrade not include C++? Thanks It depends on what you bought. If you bought Delphi 2009 only, that's what you get. If you bought Delphi 2009 and C++ Builder 2009 you get both. My guess is you got Delphi 2009 only. The simplest way to verify is look your invoice - it should say I would think. You could also go to members.embarcadero.com, login, then click on my registered products. There will be a textual description of...

Delphi 4 to Delphi 2009
Hello, Thanks to all who answered my previous question. That was a great help. And atlast our client agreed to upgrade our delphi version from 4 to Delphi 2009. *Sigh*. But before that, I need to give the estimation and cost regarding the migration to delphi 2009. Can anyone tell me is there any tool to migrate from delphi 4 to delphi 2009 or just I need to compile our Delphi 4 application in Delphi 2009. I have read from the delphi 2009 feature matrix that Delphi 1 through Delphi 2007 import is possible in delphi 2009. But i am not that sure considering the size of our application. ...

is there a Delphi 2007
Would be nice to have a bundle of the latest Delphi packages. Gilbert Padilla wrote: > Would be nice to have a bundle of the latest Delphi packages. > I expect Delphi 2007 will only be on sale until the full RAD Studio 2009 edition is published, including Delphi 2009.net. W ...

Delphi 2009 alongside Delphi 2007
Hi all, I am about to install Delphi 2009 on the same development system as Delphi 2007, before I embark is there anything I should be aware of so as to not break my Delphi 2007 installation and projects ? Thanks JT John Taylor wrote: > Hi all, > > I am about to install Delphi 2009 on the same development system > as Delphi 2007, before I embark is there anything I should be aware > of so as to not break my Delphi 2007 installation and projects ? As long as you install into a separate folder there is no problem with the two versions getting into each other...

Upgrading to Delphi 2009 from Delphi 5
I've decided it's time to upgrade to Delphi 2009 Professional from my current Delphi 5 Professional which (according to the FAQ) makes me eligible for the upgrade pricing. However, I'd just like to clarify how this process works. My concern is that my Delphi 5 is not registered on the CodeGear site and this doesn't seem to be possible as far as I can tell. When installing the trial I noticed that Delphi 2009 registers itself with your CodeGear account so does this mean that the previous version must be registered there to verify you own a Professional edition? I plan to o...

Delphi 2007 to Delphi 2009 Conversion
CharArrayPtr = ^CharArray; CharArray = array[0..MaxInt-1] of Char; How to convert to Delphi 2009? Bill Bill Miller wrote: > CharArrayPtr = ^CharArray; > CharArray = array[0..MaxInt-1] of Char; > > How to convert to Delphi 2009? > > Bill it depends heavelly on how it is used fearther down in your project and what you want to convert it to. I you want to simple convert the declarations ignoring UNicode altogether then the only think you have to change is the CharArray declaratin from a Char to an AnsiChar eg CharArrayPtr = ^CharArray; CharArray =...

Delphi 7 to Delphi 2009 conversion
Hello group, What do I need to do to comile the following code in D2009. Compiler error after the Else E2010: Incompatible Types 'AnsiChar' and 'Char' if isUnicode then SearchHandle := FindFirstFilew( PWideChar( fn ), FindDataW ) else SearchHandle := FindFirstFile( PAnsiChar( Ansistring( fn ) ), FindDataA ); <<<<<compiler error in the above line >>>>>>>>>>> Regards, Bryan > What do I need to do to comile the following code in D2009. > Compiler error after the Else > E2010: Incompati...

Why does this work fine in Delphi 2009, but not in Delphi 2010
I've been racking my head trying to figure this out and can't understand what is wrong, TFileStream.ReadComponentRes fails when I try to read a component containing a record, it works fine in Delphi 2009 and Delphi 2007, but fails with Delphi 2010 Here is the unit source and DFM *+//UnitSource+* unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TThresholdMode = (tm0,tm1,tm2,tm3,tm4,tm5); TThreshold = Record Mode:TThresholdMode; Filter,Start,Stop:Integer; end; ...

ShareMem Delphi 6 --> Delphi 2009
I have just upgraded from Delphi 6 to Delphi 2009. My software uses about 20 files, plus literally dozens more plug-ins. Every project has ShareMem as its first unit and borlndmm.dll is distributed with the software. I am aware that the Borland Memory Manager was replaced to use FastMM quite some time ago. Will I have to rebuild every EXE and DLL in DElphi 2009 that uses ShareMem, or will supplying the new borlndmm.dll be enough? i.e. I would like to just update the main application EXEs and DLLs, but leave the plug-ins alone. Will this work? Thanks, Jason. -- Jason Sweby ...

Question about Delphi 2009 vs Delphi 7
Hi, I was wondering if any of you can point me to a URLs that show the most important improvements between these versions of Delphi. The objective is convincing the powers-that-pay-the-bills that moving to D2009 (that we'd have to purchase) is a better idea than moving to D7 (for which we have licenses). Fire at will! -- Saluti, Alessandro Federici ------------------------------- "I have been through some terrible things in my life, some of which actually happened." (Mark Twain) Alessandro Federici wrote: > Hi, > I was wondering if any of yo...

Migrate from Delphi 2007 for Win32 to Delphi XE
we use Delphi 2007 for Win32 to support legacy (32Bit) OWL-based pascal applications (yes i know it was a mistake not to switch to VCL 15 years ago). could our applications still be opened and compiled with Delphi XE? The existing projects are all plain Pascal-Code, coming back from the times of Turbo Pascal for Windows and later on Borland Pascal. Are there any improvements we could profit from (i.e IDE, Debugger)? Thanks Andrej > {quote:title=Andrej Dimic wrote:}{quote} > could our applications still be opened and compiled with Delphi XE? I'm not sure, but I guess ...

Code Porting
Hi people, Basically, I am moving an app from Delphi 5 to Delphi 2009 which is all great (yeah right!) and I am having a couple of issues with some thirdparty components that we have the source code for. Being that I wanted to make the task as easy as possible, I was able to download the component in Delphi 2007 format. I have now managed to port that to 2009 so it compiles only with warnings and no errors. So all is good at this moment. Now I am trying to install the component into the IDE by using the install menu option from the project manager. This is where I run into errors. ...

Converting Delphi for Win32 to Delphi .Net(Prism)
Hi, I am currently migrating a project from Delphi for Win32 to Delphi.net. Part of my code currently goes into a directory and pulls out a random file from this directory and loads the contents of the file for me. This code doesn't seem to work in Delphi.Net. It uses PString and a number of functions in SysUtils that don't seem to be present in Delphi.net's SysUtils file. If anyone can help me please, it would be greatly appreciated! Many thanks, Jonathan Mackey Jonathan Mackey a écrit : > I am currently migrating a project from Delphi for Win32 to &...

ShareMem Delphi 6 --> Delphi 2009
I have just upgraded from Delphi 6 to Delphi 2009. My software uses about 20 files, plus literally dozens more plug-ins. Every project has ShareMem as its first unit and borlndmm.dll is distributed with the software. I am aware that the Borland Memory Manager was replaced to use FastMM quite some time ago. Will I have to rebuild every EXE and DLL in DElphi 2009 that uses ShareMem, or will supplying the new borlndmm.dll be enough? i.e. I would like to just update the main application EXEs and DLLs, but leave the plug-ins alone. Will this work? Thanks, Jason. -- Jason Sweby ...

Web resources about - Exception in Delphi 2009 when closing aan pplication that calls these two methods - embarcadero.delphi.win32

James Webb Space Telescope - Wikipedia, the free encyclopedia
The James Webb Space Telescope ( JWST ), previously known as Next Generation Space Telescope ( NGST ), is a planned space telescope optimized ...

ELIS/PARIS - Jonas Maebe
After my graduation in June 2007, I joined the Diablo team as a post-doctoral researcher.Diablo is a powerfulmulti-target link time binary rewriting ...

Alloys
Call on Accurate Specialtiesexperienced engineering and sales team to help determine which alloy and casttype best suits your application. UNS# ...

Apple Lawsuit With Proview Nearing End?
... iPad trademark in 2009 for just $55,000. At the time, Proview believed it was selling the name to a “special purpose” entity, IP A pplication ...

A
Hot Topics: IBC Special Project Horizon UK Pay-TV Review YouView Central & East Europe Dutch Edition Broadband TV News The Business of Multiscreen ...

中文簡介 - cacaFly 聖洋科技 - facebook台灣廣告總代理
... 是由一群交大的年輕朋友一同創立的 Web 2.0 網站,並獲得詹宏志先生等業界前輩的投資與指導,cacaFly 則是因應在 Facebook 時代業界對社群行銷的需求,由 funP 建構出的全新服務團隊。 cacaFly 的名稱是來自於 " C ustomized A pplications ...

11/8/94
Let’s approach this wholething here methodically and start off with a STATEMENT OF THE PROBLEMS (to be solved here): Some people A) havenose ...

City of Shoreline, WA : Jobs
City of Shoreline, WA Welcome to the City of Shoreline's application process. You can now apply online by clicking on the job title you are interested ...

I’ve got your missing links right here (19 November 2011)
Links - I'm travelling for a bit so this week's selection is a bit truncated. Also, I have limited internet access so if there are broken links ...

Fluid, Prism, Mozpad and site-specific browsers
Matt Gertner of AllPeers wrote a post the other day titled, "Wither Mozpad?" In it he poses a question about the enduring viability of Mozpad, ...

Resources last updated: 1/22/2016 2:57:44 PM