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

C++ to Delphi, Values/GUIDs

I need 2 Functions, Rater simple i guess.. if you know how that is :)

1. Convert String with '0x0300' type values into the Format we use in Delphi.

2. Convert GUIDs from C++ Headers into GUID Format we use in Delphi.
i found 2 kinds in the headers :
First: {e436eb78-524f-11ce-9f53-0020af0ba770}
Second: 0xe436eb78, 0x524f, 0x11ce, 0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70

Not very familiar with those things yet.. so i hope u guys could introduce me to the devils..
0
brainware
Asked:
brainware
1 Solution
 
intheCommented:
duno much about guids but you can use something like below :

 
const

  First : TGUID = '{3F5A62E2-51F2-11D3-A075-CC7364CAE42B}';

 Second : TGUID = (
    D1:$0000010B;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46));

do you know about guidtostring(TGuid) defined in comobj.
and cocreateguid(tguid) in activex unit.
0
 
brainwareAuthor Commented:
Well i kinda need to convert the format of the Hmm STRINGS/GUIDS whatever u wanna call them, Into Delphi Working Values.. at first the MOST Imp is the 0x0300  i checked delphi source and noticed some values i could not see any compare between the values here and the once in the Windows SDK (c++)
Noticed some ppl to like
MyConst = (1 shr 2) insted of such value .... Im only getting more confused.. :(
0
 
brainwareAuthor Commented:
i have been awake for 4 days now (in a row), But anyhows.. a page with bad english i bet, http://www.bw-soft.com
bwDelphi-Kit, Getting Developed by me and several of others, No freeware tho.. Not when it is as big as its going to be shortly..

Just if a pro like u had any interests in it..

Kinda Amature page right now.. but no time for Fancy html, Can't u see we are coding :)
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
simonetCommented:
>1. Convert String with '0x0300' type values into the
>Format we use in Delphi.

That's an hexadecimal value. To convert it to an integer, do the following:

function CHexToDInt(CHex : string) : longint;
begin
   Delete(CHex, 1, 2);   // 0x0300 -> 0300
   Result := StrToInt('$'+CHex);  // 0300 -> $0300 -> longint
end;

Yours,

Alex


0
 
MadshiCommented:
Hehe, this one is faster...   :-))

function CHexToDInt(CHex : string) : longint;
begin
   Delete(CHex, 1, 1);   // 0x0300 -> 0300
   CHex[1] := '$';
   Result := StrToInt(CHex);  // 0300 -> $0300 -> longint
end;

(-:

Regards, Madshi.
0
 
brainwareAuthor Commented:
hehe.. Well i learned that it was HEX yeah.. but what about the GUID Crap..
0
 
MadshiCommented:
Michael, do you want to convert the GUID strings with a program or simply manually? If manually, look at Barry's comment.
0
 
brainwareAuthor Commented:
Well i just need to write a small app that i give a C++ GUID and it gives me Delphi version of it...
becuse i want to port a few things of the DirectMedia SDK..
0
 
brainwareAuthor Commented:
the functions u refered me too was oki.. figured the rest out too..
thanks..
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now