Solved

incompatible types, String and PChar

Posted on 1997-10-08
2
1,017 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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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