Solved

incompatible types, String and PChar

Posted on 1997-10-08
2
1,025 Views
Last Modified: 2008-03-06
hi,

When trying to find the Windows dir I use this,

Var
WinDirLen: Integer;
WinDir: PChar;
dir : string;
Begin
GetMem(WinDir, 255);
WinDirLen := GetSystemDirectory(WinDir,255);
dir := Windir;
FreeMem(WinDir);
end;

And I have this in my FormCreate;

Image1.Picture.Bitmap.Handle:= NViewLibLoad('c:\Program Files\Empire\800x600.jpg',false);

if I use this

Image1.Picture.Bitmap.Handle:= NViewLibLoad(dir + '800x600.jpg',false);
I get incompatible types String and PChar;

Please show me how it will work.

this is in the var that follows before implementation.
function NViewLibLoad(FileName : PChar; ShowProgress: BooLean):hbitmap; Stdcall; external 'NViewLib.dll';
0
Comment
Question by:hellfire052497
[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
2 Comments
 
LVL 3

Accepted Solution

by:
mirek071497 earned 50 total points
ID: 1347070
I think so you need to know how the conversion between strings can be done.

in many ways.

Image1.Picture.Bitmap.Handle:= NViewLibLoad( PChar( string(dir) + '800x600.jpg' ),false);

when s is type PChar then String(s) give you long string.
when s is Long String then PChar(s) give you type PChar.

so in your problem string(dir) give you long string
PChar(      string(dir)+'800x600.jpg'   ) give you PChar.
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1347071
Hi

sorry i just see so dir is string no pchar. Then you can use use this without string(dir) :

Image1.Picture.Bitmap.Handle:= NViewLibLoad( PChar( dir + '800x600.jpg' ),false);

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 110
Delphi IDE crash without error message ... 7 117
Delphi...Split view - idea? 1 114
Tidtcpserver listening on multiports? 1 45
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…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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