HOW to use GetDiskSerial.dll in MQL5? - page 2

To add comments, please log in or register
Ma Yuliang
296
Ma Yuliang  

hi guys thanks a lot. I test the dll Anton Nel give me. It not work on my computer. HDD ID return "0123456789ABCD".

the reason is my computer is win8 64bit. It need Administrator right and something about 64bit.

still I learned alot from Anton Nel's code. If you can share the code of the dll we can try to fix that.

I spend two days to learn delphi. Since the string returned by the dll is PAnsiChar I use this function to change it.

Function PAnsiCharToAnsiString(PAnsi: PAnsiChar): AnsiString; stdcall;
var
  myStr: AnsiString;
  myCharPtr: PAnsiChar;
  // myPAnsiChar :PAnsiChar;
  i: Integer;
begin
  i := 0;

  myCharPtr := Addr(PAnsi[i]);

  while i <= 20 do
  begin
    myStr := myStr + (myCharPtr^);
    Inc(i);
    Inc(myCharPtr);
  end;
  Result := myStr;

end;

//Ansistring to PWideChar is easy just like this
PW      := PWideChar(WideString));


since encode and decode is not easy in mql4, I write another dll.Including encode and decode,to the get Serial Num and activation key.

they pass only PWideChar to mql4.PWideChar can be read in mql4 as string.

by the way the "GetDiskSerial.dll" is not a free soft It cost me alot.

anyway thanks every one.

Carl Schreiber
Moderator
8499
Carl Schreiber  

I just got from the German forum this for the DOS-Box:

----------------------------------------------------------------

DOS-Box started without admin.-rights:

C:\Users\cas>wmic path win32_physicalmedia get SerialNumber
SerialNumber
31535853534e4641303932383434205620202020

------------------------------------------

DOS-Box started with admin.-rights:
C:\Windows\system32>wmic path win32_physicalmedia get SerialNumber
SerialNumber
S1SXNSAF908244V

------------------------------------------

There they gave me another link.
But I guess even this would not solve this problem (not tested)

But may be the upper very long number is equivalent to the original unique hardware ID?
Anton Nel
57366
Anton Nel  
            string hexString = "31535853534e4641303932383434205620202020";
            String sb = String.Empty;
            String swap_sb = String.Empty;
            for (int i = 0; i < hexString.Length; i += 2)
            {
                string hs = hexString.Substring(i, 2);
                if (swap_sb == String.Empty)
                    swap_sb = swap_sb + Convert.ToChar(Convert.ToUInt32(hs, 16));
                else
                {
                    sb = sb + Convert.ToChar(Convert.ToUInt32(hs, 16)) + swap_sb;
                    swap_sb = String.Empty;
                }
            }
            Console.WriteLine(sb);

This is C# language. Output is S1SXNSAF908244V. Solved :-)

Carl Schreiber
Moderator
8499
Carl Schreiber  

Are you sure?

I get using this online converter for my Serial Number: S1SXNSAF908244V this: 533153584e53414639303832343456

as its hex-code which differs a bit(?) from 31535853534e4641303932383434205620202020

The initial S (=x53) is missing and ...

If I convert 31535853534e4641303932383434205620202020 to a string I get: 1SXSSNFA092844 V.

It is not the same :(

Convert String To Hexadecimal Online
Convert String To Hexadecimal Online
  • string-functions.com
Enter the text to encode to hex, and then click "Convert!": The encoded string:   > Hex to text converter Hexadecimal notation is used as a human-friendly representation of binary values in computer programming and digital electronics. Most programming languages such as Java, ASP.NET, C++, Fortran etc have built-in functions that convert to...
Anton Nel
57366
Anton Nel  

31 = 1

53 = S

as one block.

Read as S1

i think it has something to do with Unicode. 

Carl Schreiber
Moderator
8499
Carl Schreiber  

Hmm - I see nearly all the char I have but in a different sequence? How that?

org: S1SXNSAF908244V

hex: 1SXSSNFA092844 V

S1SXN => 1SXSSN

SAF => NFA

908244 => 092844

some are pair-wise switched?

Strange? May be creative computer art?

Anton Nel
57366
Anton Nel  
calli:

Hmm - I see nearly all the char I have but in a different sequence? How that?

org: S1SXNSAF908244V

hex: 1SXSSNFA092844 V

S1SXN => 1SXSSN

SAF => NFA

908244 => 092844

some are pair-wise switched?

Strange? May be creative computer art?

Ja computer is trying to play the game. :-) 
Anton Nel
57366
Anton Nel  

When you googled you will find some people have mentioned same issue with this pair-swapped ~ different stories - they think it is a bug and others thinks it is a security purpose.

Convert 31535853534e4641303932383434205620202020 to a string and you get: 1SXSSNFA092844 V:

[1S] [XS] [SN] [FA] [09] [28] [44] [ V] = 1SXSSNFA092844 V

Swap the pair:

[S1] [XS] [NS] [AF] [90] [82] [44] [V ] = S1SXNSAF908244V 

Carl Schreiber
Moderator
8499
Carl Schreiber  
Anton Nel:

When you googled you will find some people have mentioned same issue with this pair-swapped ~ different stories - they think it is a bug and others thinks it is a security purpose.

Convert 31535853534e4641303932383434205620202020 to a string and you get: 1SXSSNFA092844 V:

[1S] [XS] [SN] [FA] [09] [28] [44] [ V] = 1SXSSNFA092844 V

Swap the pair:

[S1] [XS] [NS] [AF] [90] [82] [44] [V ] = S1SXNSAF908244V 

But this simple algorithm means you can use the hex number the user can get as an id for the hd, as another hd will have another id and that causes a different hex code!
12
To add comments, please log in or register