ArianeSoft - Programming and development for Windows and Windows Mobile :: Forums :: PPL - Pocket Programming Language :: Code sharing
 
<< Previous thread | Next thread >>
Retrieve hard drive serial number on PC
Moderators: kornalius, bmanske, PointOfLight
Author Post
kornalius
Tue May 20 2008, 10:28am


Registered Member #1
Joined: Wed Apr 19 2006, 08:25pm
Posts: 2783
Here is a little piece of code to retrieve the hard drive C: serial # in PPL. This code only works on the PC.

#ifdef _WIN32
#declareapi GetVolumeInformation kndll GetVolumeInformation 8 1

new(vserial$, tint);

GetVolumeInformation("C:\\", NULL, 0, &vserial$, NULL, NULL, NULL, 0);

sprintf(serial$, "0x%4X%4X", HiWord(vserial$), LoWord(vserial$));
ShowMessage(serial$);
#endif


Regards,
Alain Deschenes
President and programmer
ArianeSoft Inc. (http://www.arianesoft.ca)
Back to top
Mike Halliday
Tue May 20 2008, 12:17pm

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
Hhhmm, I can see a great use for that!

Q: What is KNDLL? I have googled it, but not found anything useful. What is the equiv DLL file on the PPC?

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
PointOfLight
Tue May 20 2008, 04:28pm

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
kndll is a define which can be found in defs.ppl.  On the PC kndll is kernel32.dll.  On the PPC, it is coredll.dll (no, that's not a typo - it's just redundant )

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Mike Halliday
Tue May 20 2008, 05:20pm

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
- should have known it would be that easy!

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
DirectDance
Wed May 21 2008, 06:52am
Registered Member #11
Joined: Mon Jul 03 2006, 06:15am
Posts: 157
Many thanks for this !

Perfect for implementing protection into our programs on PC.
Back to top
Mike Halliday
Fri Jun 13 2008, 08:29am

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
Alain, I need a few pointers on how the above works;

I have the following code;

#declareapi GetComputerName kndll GetComputerName 2 1
func ComputerName()
new(cpu$,16);
cpu$ = "";
GetComputerName(&cpu$, 16);
return (cpu$);
end;

When I do this;
writeln("NetBios Name:" + ComputerName());

I can an access violation error.

What have I done wrong? I have searched the net on how Kernel32 functions work and thought I had it right?

Cheers

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
PointOfLight
Fri Jun 13 2008, 12:00pm

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
Here's a revised version of your function:

#define MAX_COMPUTERNAME_LENGTH 15

func ComputerName()
  new(sz$, TLong);
  new(cpu$,MAX_COMPUTERNAME_LENGTH + 1);
  &cpu$ = "";
  sz$ = MAX_COMPUTERNAME_LENGTH + 1;
  GetComputerName(&cpu$, &sz$);
  return(cpu$);
end;

This works, and I'm not sure exactly what fixed it, though I'd wager it was the & in front of cpu$ when doing the initial assignment.

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Mike Halliday
Fri Jun 13 2008, 02:07pm

Registered Member #671
Joined: Tue Sep 25 2007, 12:22pm
Posts: 400
Oh I see what I did wrong. (I think) - I will have a go at some more dll calls and see if I can work it out from yout code.

Thanks Eric.

Editor of \'Voice of the PPL\' the newsletter for the PPL by the PPL!

Still trying to get people to contribute to the newsletter!
Back to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System