Pilo,
Si hacer la función envoltura le supone un problema puede hacerlo también como le comento Xevi, creo recordar:
- WINEXEC( "VOL C: > VOL.TXT" )
- cVol := MEMOREAD( "VOL.TXT" )
- Los 9 últimos caracteres de la cadena cVol contienen el numero de serie
- FERASE( "VOL.TXT" )
Saludos,
"Ignacio Ortiz de Zúñiga" <
NoName@xailer.com> escribió en el mensaje news:44a54666$[email=
1@news.xailer.com...]
1@news.xailer.com...[/email]
Pilo,
Esta es la función del API de Windows que retorna dicha información:
GetVolumeInformation
The GetVolumeInformation function retrieves information about a file system and volume that have a specified root directory.
BOOL GetVolumeInformation(
LPCTSTR lpRootPathName,
LPTSTR lpVolumeNameBuffer,
DWORD nVolumeNameSize,
LPDWORD lpVolumeSerialNumber,
LPDWORD lpMaximumComponentLength,
LPDWORD lpFileSystemFlags,
LPTSTR lpFileSystemNameBuffer,
DWORD nFileSystemNameSize
);
Parameters
lpRootPathName
[in] A pointer to a string that contains the root directory of the volume to be described.
If this parameter is NULL, the root of the current directory is used. A trailing backslash is required. For example, you would specify MyServerMyShare as MyServerMyShare, or the C drive as "C:".
lpVolumeNameBuffer
[out] A pointer to a buffer that receives the name of a specified volume.
nVolumeNameSize
[in] The length of a volume name buffer, in TCHARs.
This parameter is ignored if the volume name buffer is not supplied.
lpVolumeSerialNumber
[out] A pointer to a variable that receives the volume serial number.
This parameter can be NULL if the serial number is not required.
Windows Me/98/95: If the queried volume is a network drive, the serial number is not returned.
lpMaximumComponentLength
[out] A pointer to a variable that receives the maximum length, in TCHARs, of a file name component supported by a specified file system.
A file name component is the portion of a file name between backslashes.
The value that is stored in variable pointed to by *lpMaximumComponentLength is used to indicate that long names are supported by a specified file system. For example, for a FAT file system that supports long names, the function stores the value 255, rather than the previous 8.3 indicator. Long names can also be supported on systems that use the NTFS file system.
lpFileSystemFlags
[out] A pointer to a variable that receives flags associated with the specified file system.
This parameter can be one or more of the following flags; however, FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED are mutually exclusive.
Value Meaning
FILE_NAMED_STREAMS The file system supports named streams.
FILE_READ_ONLY_VOLUME The specified volume is read-only.
Windows 2000/NT and Windows Me/98/95: This value is not supported.
FILE_SUPPORTS_OBJECT_IDS The file system supports object identifiers.
FILE_SUPPORTS_REPARSE_POINTS The file system supports re-parse points.
FILE_SUPPORTS_SPARSE_FILES The file system supports sparse files.
FILE_VOLUME_QUOTAS The file system supports disk quotas.
FS_CASE_IS_PRESERVED The file system preserves the case of file names when it places a name on disk.
FS_CASE_SENSITIVE The file system supports case-sensitive file names.
FS_FILE_COMPRESSION The file system supports file-based compression.
FS_FILE_ENCRYPTION The file system supports the Encrypted File System (EFS).
FS_PERSISTENT_ACLS The file system preserves and enforces access control lists (ACL). For example, the NTFS file system preserves and enforces ACLs, and the FAT file system does not.
FS_UNICODE_STORED_ON_DISK The file system supports Unicode in file names as they appear on disk.
FS_VOL_IS_COMPRESSED The specified volume is a compressed volume; for example, a DoubleSpace volume.
lpFileSystemNameBuffer
[out] Pointer to a buffer that receives the name of the file system (such as the FAT file system or the NTFS file system).
nFileSystemNameSize
[in] Length of the file system name buffer, in TCHARs. This parameter is ignored if the file system name buffer is not supplied.
Return Values
If all the requested information is retrieved, the return value is nonzero.
If not all the requested information is retrieved, the return value is zero (0). To get extended error information, call GetLastError.
Remarks
If you are attempting to obtain information about a floppy drive that does not have a floppy disk or a CD-ROM drive that does not have a compact disc, the system displays a message box asking the user to insert a floppy disk or a compact disc, respectively. To prevent the system from displaying this message box, call the SetErrorMode function with SEM_FAILCRITICALERRORS.
The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-based compression. The file system name is not altered to indicate compression. This flag comes back set on a DoubleSpace volume, for example. With volume-based compression, an entire volume is either compressed or not compressed.
The FS_FILE_COMPRESSION flag indicates whether a file system supports file-based compression. With file-based compression, individual files can be compressed or not compressed.
The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are mutually exclusive; both bits cannot come back set.
The maximum component length value, stored in lpMaximumComponentLength, is the only indicator that a volume supports longer-than-normal FAT file system (or other file system) file names. The file system name is not altered to indicate support for long file names.
The GetCompressedFileSize function obtains the compressed size of a file. The GetFileAttributes function can determine whether an individual file is compressed.
Example Code
For an example, see Enumerating Mount Points.
Requirements
Client Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header Declared in Winbase.h; include Windows.h.
Library Link to Kernel32.lib.
DLL Requires Kernel32.dll.
Unicode Implemented as GetVolumeInformationW (Unicode) and GetVolumeInformationA (ANSI). Note that Unicode support on Windows Me/98/95 requires Microsoft Layer for Unicode.
"PILO" <
srmpilo@hotmail.com> escribió en el mensaje news:44a52524$[email=
1@news.xailer.com...]
1@news.xailer.com...[/email]
"Jose F. Gimenez" <
jfgimenez@wanadoo.es> escribió en el mensaje news:[email=
447ea695@ozsrvnegro.ozlan.local...]
447ea695@ozsrvnegro.ozlan.local...[/email]
Pilo,
hola Ignacio o a cualquiera que me pueda ayudar en esto.
Necesito la idea de proteger mi programa contra pirateria como haces
en el vuestro, una idea de leer el numero de serie del disco duro,otra la direccion mac de tarjetas de red
o otras el numero de serie de microprocesador.
¿Como puedo hacer alguna de las anteriores?
No es nada sencillo escoger una cosa u otra.
1) El n/s del disco duro se puede leer más o menos fácilmente desde W2K o XP, pero no así desde W98 o ME.
2) La dirección MAC de las tarjetas de red no es lo más apropiado, en mi opinión, porque el usuario puede cambiar la tarjeta en cualquier momento, o tener varias o incluso cambiar la MAC.
3) El Procesador NO tiene n/s. Lo tuvo el Pentium III pero lo tuvieron que quitar en el P4 debido a la enorme cantidad de críticas que surgieron por la falta de privacidad que eso podía originar.
Cual es la opcion para poder proteger un programa una idea, me puede mandarlos a la direccion privada de
srmpilo@hotmail.com
Por desgracia no hay ningún "número mágico" en el ordenador que se pueda usar para una protección anti-copia. La técnica más habitual es usar varios de esos "números" (p.ej. n/s del volumen y/o del disco duro, la dirección MAC, modelo de la tarjeta de video, etc.) y guardarlos. Después, cuando arranca el programa, se vuelven a comprobar, y si la mayoría (p.ej. 3 de 5) son correctos continuar; en caso contrario, salir del programa con un aviso.
La otra vía es usar mochilas (o como quieras llamarlas). Pero tienen principalmente 3 inconvenientes:
1) Tienen un coste extra
2) Son incómodas para el usuario
3) Suelen tener la mala costumbre de estropearse de vez en cuando, dejando al usuario completamente parado. Y lo peor es que continuará parado hasta que consigas hacerle llegar otra mochila nueva; es imposible solucionarle el problema por teléfono o por internet.
--
Un saludo,
José F. Giménez
http://www.xailer.com
--