Icon View Thread

The following is the text of the current message along with any replies.
Messages 21 to 23 of 23 total
Thread EDB error #406
Wed, Feb 21 2007 11:20 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tom,

<< My machine has a NIC connected to a router which connects to a cable
modem. A second machine connected to the router can get to a shared folder
on my machine. >>

In that case it probably is not using NetBios names.  You can use:

NET VIEW

to see if the current machine is assigned a NetBios name.  It should be the
first item listed.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Feb 21 2007 6:56 PMPermanent Link

Tom Unger
Tim,

I think I found the problem. In the function TEDBEnvironment.GetComputerName I changed the line:

ResultLength:=MAX_COMPUTERNAME_LENGTH ;
to
ResultLength:=MAX_COMPUTERNAME_LENGTH +1;

It looks like the previous line would have zeroed out the final char already, so I'm puzzled why this changes anything.
But I have tested the function both on my home machine and my work machine.

On both machines I get a result with a length of 15, but appearing blank with ShowMessage, using ResultLength:=MAX_COMPUTERNAME_LENGTH ;
Changing to ResultLength:=MAX_COMPUTERNAME_LENGTH +1; correctly returns the computer name on both boxes.

Hope this helps.

function TEDBEnvironment.GetComputerName: TEDBString;
var
  TempBuffer: array[0..MAX_COMPUTERNAME_LENGTH] of TEDBChar;
  ResultLength: DWORD;
begin
  FillChar(TempBuffer,((MAX_COMPUTERNAME_LENGTH+1)*SizeOf(TEDBChar)),0);
  ResultLength:=MAX_COMPUTERNAME_LENGTH +1;
  Windows.GetComputerName(@TempBuffer,ResultLength);
  SetLength(Result,ResultLength);
  Move(TempBuffer[0],pEDBChar(Result)^,(ResultLength*SizeOf(TEDBChar)));

end;


Thu, Feb 22 2007 6:56 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tom,

<< I think I found the problem. In the function
TEDBEnvironment.GetComputerName I changed the line:

ResultLength:=MAX_COMPUTERNAME_LENGTH ;
to
ResultLength:=MAX_COMPUTERNAME_LENGTH +1;

It looks like the previous line would have zeroed out the final char
already, so I'm puzzled why this changes anything. >>

I just double-checked what MAX_COMPUTERNAME_LENGTH is set to.  I was under
the impression that it was larger than it is.  However, it is only 15, so
that means that your computer name length of 15 characters is hitting the
limit, thus causing the problem.  Of course, it would help if the Windows
API was a little more consistent about when it wants the NULL terminator
included in the buffer length passed in to the API functions.  Some
functions want it, and others don't.

--
Tim Young
Elevate Software
www.elevatesoft.com

« Previous PagePage 3 of 3
Jump to Page:  1 2 3
Image