PDA

View Full Version : Need help..


ctanl
06-11-2009, 12:34 PM
Hi all,

I am very new in AMS.

I have created a project but i want to bind it in my pendrive.So,I have decided to use script below. But, I have no idea how to get the serial number from my pendrive.Anyone can help me?Thanks in advance:)

Script
-- Set this value to the expected serial number of the
-- drive that your application will run from.
Expected_Serial = 123456789;

-- Gets the source drive's current serial number
Current_Serial = Drive.GetInformation(_SourceDrive).SerialNumber;

-- Compares the two serials and, if different, terminates the app.
if (Current_Serial ~= Expected_Serial) then
Dialog.Message("ERROR", "This is an unauthorized copy of the original application, and will shut down.", MB_OK, MB_ICONSTOP);
Application.Exit();
end

holtgrewe
06-11-2009, 01:45 PM
This does not answer your question directly but with this code you should be able to extract ideas to accomplish what you want.

Place the following code on a button ON Click...

dtbl = Drive.Enumerate()

for x,y in dtbl do

Dinfo = Drive.GetInformation(""..dtbl[x])
if Dinfo then
Dtype=Drive.GetType(""..dtbl[x])
if Dtype == 0 then Dtypex = "Unknown"
elseif Dtype == 1 then Dtypex = "Invalid"
elseif Dtype == 2 then Dtypex = "Removable"
elseif Dtype == 3 then Dtypex = "Fixed"
elseif Dtype == 4 then Dtypex = "Remote"
elseif Dtype == 5 then Dtypex = "CDRom"
elseif Dtype == 6 then Dtypex = "RamDisk"
end
Dsize=Drive.GetSize(""..dtbl[x])
Dfree=Drive.GetFreeSpace(""..dtbl[x])
Dialog.Message("USB Drive "..String.Left(dtbl[x],2).." ", "Name: "..Dinfo.Label.."\r\nSerial #: "..Dinfo.SerialNumber.."\r\nSystem Name: "..Dinfo.DisplayName.."\r\nType: "..Dtypex.."\r\nCapacity in Mb: "..Dsize.."\r\nSpace Available in Mb: "..Dfree.."\r\n")
else
Dialog.Message("USB Drive "..String.Left(dtbl[x],2).." ", "Drive not found")
end
end

ctanl
06-11-2009, 02:44 PM
hi holtgrewe,
thanks for your reply,i am still very confuse...

longedge
06-11-2009, 04:21 PM
It's a two stage process as far as I can see. Build the attached example to an .exe drop it onto a memory stick and run it. It'll get the serial number and copy it to the clipboard. Close the application and delete it from the memory stick. Now paste the serial into your main application and then build it. Using your idea it should only run on that memory stick.

ctanl
06-11-2009, 05:16 PM
hi longedge,
thanks for your reply,the project shows error and cannot be run."Page1 -> On Show,Line 1 :Argument 1 must be of type string"

if String.Left(_CommandLineArgs[1], 3) == "SFX" then
strPath = String.Replace(_CommandLineArgs[1], "SFXSOURCE:", "", true)
strPath = String.SplitPath(strPath)
drv = strPath.Drive
drvinfo = Drive.GetInformation(drv);
serial= drvinfo.SerialNumber
Label.SetText("Label1", serial);
Clipboard.CopyText(serial);
Paragraph.SetVisible("Paragraph1", true);
end

longedge
06-12-2009, 01:22 AM
hi longedge,
thanks for your reply,the project shows error and cannot be run."Page1 -> On Show,Line 1 :Argument 1 must be of type string"

Yes it needs some error trapping, it's just the bare bones and needs tidying up - you *MUST* build it to an exe and then it will run OK. In the build options choose (from memory) " Web executable ".

Because it's just a 'tool' to use temporarily it makes much more sense to have it as a single .exe in any case.

longedge
06-12-2009, 02:39 AM
Try -


if _CommandLineArgs[1] then
serial = (Drive.GetInformation(((String.SplitPath(String.Re place(_CommandLineArgs[1], "SFXSOURCE:", "", true))).Drive))).SerialNumber;
Label.SetText("Label1", serial);
Clipboard.CopyText(serial);
Paragraph.SetVisible("Paragraph1", true);
else
result = Dialog.Message("N.B.", "You must compile this application to a \"Web\/Email Executable\" for it to work correctly.\r\n\r\nApplication will close when you click \"OK\"", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Application.Exit();
end


-- now to get some work done :)

ctanl
06-12-2009, 05:59 AM
thanks longedge,it works perfectly.i have modified the script and it works perfectly and binded in memory stick.
Thanks alot :)