• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 730
  • Last Modified:

Trying to rebuild old Delphi into new app

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
141ANG
Asked:
141ANG
  • 10
  • 8
  • 2
  • +1
3 Solutions
 
CodedKCommented:
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
 
wimmeyvaertCommented:
0
 
141ANGAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
CodedKCommented:
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
 
briangochnauerCommented:
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
 
141ANGAuthor Commented:
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
 
briangochnauerCommented:
The question was answered from several valid perspectives, even though the question was vague.
0
 
141ANGAuthor Commented:
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
 
briangochnauerCommented:
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
 
141ANGAuthor Commented:
If I walked you through that process would it help?
0
 
briangochnauerCommented:
If you want to.
0
 
briangochnauerCommented:
I downloaded the installer (instead of the source) and installed it.
That made it easier... :))
Can you reproduce the problems?
 
0
 
141ANGAuthor Commented:
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
 
briangochnauerCommented:
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
 
141ANGAuthor Commented:
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
 
briangochnauerCommented:
>>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
 
141ANGAuthor Commented:
Thanks man, do you want to keep dorking with the SYS tray thing, or call it?
0
 
141ANGAuthor Commented:
Also, could you possibly zip the source code so I can look through it and see what you did?
0
 
briangochnauerCommented:
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
 
141ANGAuthor Commented:
Thank you for all of the help. Maybe I can find someone in the RocketDock community that is up for the challenge.
0
 
141ANGAuthor Commented:
Great job, put way more time into this than I ever expected.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 10
  • 8
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now