Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO ADD Another set of numbers to string

Status
Not open for further replies.

xDeaDLy

Programmer
Jul 20, 2009
4
US
So let's say i have this string in my var
ID : String = 'TEST1';

How can i add another set of numbers and letters like 'TEST2' in that same string?
ID : String = 'TEST1','TEST2';

It gives me an error when i put it like this. THX FOR ANY HELP!
 
Code:
ID := ID + ',''TEST2''';

?

Measurement is not management.
 
Hmm will that work, Im tryin to make it Anti Leak and only registered to certain numbers so lemme give this a try
 
No it does not work, there is a function in my program that gets a Unique id from the computer and checks if it matches the one in the ID : string = that is where i am stuck, i can add my unique id in that string but i want to add multiple.
 
Can you specify which version of Delphi you are using? We're assuming that you are using Delphi as this is the Delphi forum.

When you say It gives me an error can you tell us the exact error message you are getting and whether this is a compiler or run time error?

Please show us the exact code which is causing the problem. It would help those who are helping you if you could wrap the code in TGML tags so the code is displayed in boxes (as in Glenn's post).

Although I don't completely understand your problem, it might be worth looking at the TStringList component. This allows you to add, delete and search for strings in a very simple way. You can specify if you want to allow duplicates or not.

Andrew
Hampshire, UK
 
I am using Delphi 2007. Well yes i am looking to make a list of strings, because this function prevents unauthorized usage. It searches for the Hardware ID and matches it to the string and i am trying to add multiple hardware id's for my clients. here is the function
Code:
var
HardID : String = 'MYHARDWAREID';

function GetHardwareID():string;
var
  hOpen:    HKEY;
  sBuff:    array[0..256] of char;
  BuffSize: integer;
begin
  if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, PChar('SOFTWARE\Microsoft\Windows NT\CurrentVersion'), 0, KEY_QUERY_VALUE, hOpen)) = ERROR_SUCCESS then
  begin
    BuffSize := SizeOf(sBuff);
    RegQueryValueEx(hOpen, PChar('ProductId'), nil, nil, @sBuff, @BuffSize);
    Result := sBuff;
    RegCloseKey(hOpen);
  end;
end;
begin
if GetHardwareID = HardID then
Form4.show
else
Application.Terminate;

The error is that i am tryin to put multiple hardware ID in that HardID : String but do not noe how. If anyone knows how to put multiple id's then please let me noe thank you.
 
I would recommend using the TStringList class (not a component as I suggested earlier).

TStringList is widely used in Delphi applications because it is so useful. I suggest that you read about it and then use it.

The Delphi 7 Help has an example of how to use TStringLists.

Have a go at understanding TStringList and then use it to create a list of HardIDs in your program. If you get stuck show us your code, the problem and any error messages. There are numerous folk in this forum who will be able to help you.

I could give you the code to do what you want but you will learn much more if you try to do it yourself.

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top