Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

incompatible types, String and PChar

Posted on 1997-10-08
2
Medium Priority
?
1,046 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

886 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