Solved

Trying to rebuild old Delphi into new app

Posted on 2010-09-14
22
726 Views
Last Modified: 2013-11-23
I have been trying to rebuild an old app that was written in Delphi because the controll locks up in win7. Anyway when I try to recompile I get a ton of errors. The first of which is [DCC Error] KkIni.pas(311): E2010 Incompatible types: 'AnsiChar' and 'Char'

OemToCharBuffW(PAnsiChar(BR), PAnsiChar(BR), Length(BR));

Open in new window

0
Comment
Question by:141ANG
  • 10
  • 8
  • 2
  • +1
22 Comments
 
LVL 16

Expert Comment

by:CodedK
ID: 33679370
Hi.
First try OemToCharBuffA.

If you use Delphi 2009 then replace PChar with PAnsIChar.
PChar is a PWideChar and Char is a WideChar in Delphi 2009.
You cannot assign an AnsiChar / PAnsiChar to a WideChar / PWideChar,
and vice versa, without extra coding.


function OemToCharBuffA(lpszSrc: PAnsiChar; lpszDst: PAnsiChar; cchDstLength: DWORD): BOOL; stdcall;

function OemToCharBuffW(lpszSrc: PWideChar; lpszDst: PWideChar; cchDstLength: DWORD): BOOL; stdcall;

Hope this helps.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 33679378
0
 
LVL 1

Author Comment

by:141ANG
ID: 33685847
replacing the first one worked, but not on the second line, I tried looking through the other link but it doesn't make a huge amount of sense to me, totaly a newb.

OemToCharBuffA(PWideChar(Result), PWideChar(Result), Length(AOem));

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:CodedK
ID: 33686096
Try this :

function StringToWideString(const s: RawByteString): WideString;
var
    l: integer;
    cp: Word;
begin
    if s = '' then
        Result := ''
    else
    begin
        cp := StringCodePage(s);
        l := MultiByteToWideChar(cp, MB_PRECOMPOSED, PAnsiChar(s), Length(s), nil, 0);
        SetLength(Result, l-1);
        if l > 1 then
            MultiByteToWideChar(cp, MB_PRECOMPOSED, PAnsiChar(s), Length(s), PWideChar(Result), l);
    end;
end;


Which can be simplified to this:

function StringToWideString(const s: RawByteString): WideString;
begin
Result := s;
end;
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 33694611
Hi 141ANG,
  So you did find a compiler...

You can safely comment that line out since Delphi string is UnicodeString (Widestring)

function KkUnicodeToOem(const AUnicode: WideString): String;
  var
    BR: WideString;
begin
  BR := AUnicode;
//  OemToCharBuffW(PWideChar(BR), PWideChar(BR), Length(BR));
  Result := BR;
end;

function KkOemToUnicode(const AOem: String): WideString;
begin
  Result := AOem;
//  OemToCharBuffW(PWideChar(Result), PWideChar(Result), Length(AOem));
end;
0
 
LVL 1

Author Comment

by:141ANG
ID: 33804127
That worked but now the next section is throwing an error, Undeclared identifier: 'ToString'

function TKkWideStringList.ToString(
  const ADelimiter: WideString): WideString;
  var
    BI: Integer;
begin
  Result := '';
  for BI := 0 to Count-1 do begin
    if BI > 0 then Result := Result + ADelimiter;
    Result := Result + Strings[BI];
  end;
end;

Open in new window

0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34019150
The question was answered from several valid perspectives, even though the question was vague.
0
 
LVL 1

Author Comment

by:141ANG
ID: 34020091
Brian, I don't think I ever posted the link to the original source code, if you have time to take a look here it is. http://rocketdock.com/addon/docklets/1004
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34020243
I did download the code on another question you posted.
I've been coverting thousands of lines of code to Delphi XE in the last couple months;
But the real problem I have is that I don't know what the plug-in is *supposed* to do; or even how to successfully install a plug-in inside rocketdock
I did install rocketdoc after our last question/answer exchange.
0
 
LVL 1

Author Comment

by:141ANG
ID: 34020277
If I walked you through that process would it help?
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34020323
If you want to.
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34022836
I downloaded the installer (instead of the source) and installed it.
That made it easier... :))
Can you reproduce the problems?
 
0
 
LVL 1

Author Comment

by:141ANG
ID: 34023820
So, I have gotten reports from other folks, and have experience myself that it lags quite a bit on 7, I have also noticed that the task tray function doesn't work at all.
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 34035739
Yes I can confirm the issue with no tray support on Win7;
I have not seen the 'lag' on Win7.
btw, the files he released as 'source code' is NOT the source to the last release that was made.  
It took about 20 hrs of work to get the kkmenu.dll to compile and run properly.
No sure it's any better or worse than the original.
I got the task tray function to work on XP; but I must be missing the point of why showing some of the system try icons on KKMenu is useful.
KKMenu server will not run because it can not register it's window class; but the class style is zero so it has no class; and no comments in the source code either;
When you installed KKMenu on Win7 did you install with "No Tray Support" option?
 
0
 
LVL 1

Author Comment

by:141ANG
ID: 34042354
I see what you are saying. I think that the point of the tray icon support was so that you could completely get rid of the windows bar all together.However; if it is as massive an undertaking as you are saying I will go ahead and make the suggestion to folks wanting to get rid of their windows bar to install lightstep or some other alternative shell, lol. I am sorry this ended up being so difficult. If you want to keep trying let me know. Otherwise I will assign you the points and call it good. P.S. do you have a copy of that recompiled code somewhere?
0
 
LVL 5

Accepted Solution

by:
briangochnauer earned 500 total points
ID: 34044663
>>do you have a copy of that recompiled code somewhere?
I guess you mean the DLL; I attached it.
It may or may not work better since he never released the latest source code.

KkMenu.dll
0
 
LVL 1

Author Comment

by:141ANG
ID: 34044928
Thanks man, do you want to keep dorking with the SYS tray thing, or call it?
0
 
LVL 1

Author Comment

by:141ANG
ID: 34044942
Also, could you possibly zip the source code so I can look through it and see what you did?
0
 
LVL 5

Assisted Solution

by:briangochnauer
briangochnauer earned 500 total points
ID: 34045185
There is much 'test' commenting of the code; but as is; it compiles under Delphi XE (should compile fine under Delphi version >= 2009
I enjoyed the challenge, but I have to get back to fixing some of the stuff they pay me to do. :)  it's sad that there is such few comments in the code;
The KIni.pas file should be depreciated; it only exists because it was originally written in Delphi 5 or earlier.

KKMENU-BG.exe
0
 
LVL 1

Assisted Solution

by:141ANG
141ANG earned 0 total points
ID: 34045225
Thank you for all of the help. Maybe I can find someone in the RocketDock community that is up for the challenge.
0
 
LVL 1

Author Closing Comment

by:141ANG
ID: 34078464
Great job, put way more time into this than I ever expected.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
This is about my first experience with programming Arduino.

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