Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:54:18+00:00 2026-06-05T04:54:18+00:00

I am compiling my application in Delphi XE2 .It was developed in delphi 7.

  • 0

I am compiling my application in Delphi XE2.It was developed in delphi 7.. My code is as follows:

type
 Name = array[0..100] of PChar;
 PName = ^Name;
var
  HEnt: pHostEnt;
  HName: PName;
  WSAData: TWSAData;
  i: Integer;

begin
     Result := False;
     if WSAStartup($0101, WSAData) <> 0 then begin
     WSAErr := 'Winsock is not responding."';
       Exit;
     end;
    IPaddr := '';
    New(HName);


 if GetHostName(HName^, SizeOf(Name)) = 0 then <-----ERROR
   begin
      HostName := StrPas(HName^);      

      HEnt := GetHostByName(HName^);    
            "
            "
         so on...
   end;

When i try to compile the code ,i get the following error:
enter image description here

When i try this code in another application it works fine in Delphi 7.
How do i convert from character pointer to PAnsiChar type to make it run on Delphi XE2??.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:54:20+00:00Added an answer on June 5, 2026 at 4:54 am

    My Delphi knowledge might be a little rusty, but as far as I remember:

    PChar is (kind of like, not exactly) a pointer to a string in itself, so this type is actually an array of 101 PChars (strings):

    Name = array[0..100] of PChar;

    I think you should change it to array [0..100] of Char, or why not declare HName as a PAnsiChar right from the start?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem compiling an application which uses Core-Plot in debug mode. It
While Compiling the WPF Application for many times in a day it give following
I get this error when compiling a C# application. Looks like a trivial error,
Can anyone please tell me why compiling a C# application with a .cs file
When compiling my wxWidget HelloWorld application, I am getting the following errors: Warning 1
I try to compile and link my application in 2 steps : Compiling: g++
I'm currently developing an iPhone application, and when it comes to compiling, I have
Summing up, my problem consists on compiling g95 objects inside a C++ application. Actually,
After compiling my application in Netbeans and running the application in Netbeans it works
I have read under: Compiling Web Application Projects ( http://msdn.microsoft.com/en-us/library/aa983464.aspx ) ... this compilation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.