GUID全球唯一标识符

合集下载

C#中的Guid

C#中的Guid

C#中的Guid原⽂:⼀、全局唯⼀标识符(GUID,Globally Unique Identifier)什么是GUID也称作 UUID(Universally Unique IDentifier) 。

GUID是⼀种由算法⽣成的⼆进制长度为128位的数字标识符。

GUID主要⽤于在拥有多个节点、多台计算机的⽹络或系统中。

为什么要使⽤GUID在理想情况下,任何计算机和计算机集群都不会⽣成两个相同的GUID。

GUID 的总数达到了2^128(3.4×10^38)个,所以随机⽣成两个相同GUID的可能性⾮常⼩,但并不为0。

GUID⼀词有时也专指微软对UUID标准的实现。

(1). GUID(全局统⼀标识符)是指在⼀台机器上⽣成的数字,它保证对在同⼀时空中的所有机器都是唯⼀的。

通常平台会提供⽣成GUID的API。

⽣成算法很有意思,⽤到了以太⽹卡地址、纳秒级时间、芯⽚ID码和许多可能的数字。

GUID的唯⼀缺陷在于⽣成的结果串会⽐较⼤。

(2). GUID永远是⽅便的对于程序开发的各个⽅⾯,.NET Framework简化了建⽴和处理GUID数值的过程。

在.NET程序需要的地⽅,这⼀功能很容易地⽣成唯⼀的数值。

⼆、Guid转换为字符串Guid u= Guid.NewGuid();var uuid = u.ToString(); // 9af7f46a-ea52-4aa3-b8c3-9fd484c2af12Console.WriteLine(uuid);var uuidD = u.ToString("D"); // 9af7f46a-ea52-4aa3-b8c3-9fd484c2af12Console.WriteLine(uuidD);var uuidN = u.ToString("N"); // e0a953c3ee6040eaa9fae2b667060e09Console.WriteLine(uuidN);var uuidB = u.ToString("B"); // {734fd453-a4f8-4c5d-9c98-3fe2d7079760}Console.WriteLine(uuidB);var uuidP = u.ToString("P"); // (ade24d16-db0f-40af-8794-1e08e2040df3)Console.WriteLine(uuidP);var uuidX = u.ToString("X"); // {0x3fa412e3,0x8356,0x428f,{0xaa,0x34,0xb7,0x40,0xda,0xaf,0x45,0x6f}}Console.WriteLine(uuidX);返回:c6bb19be-8095-4a3d-81af-6e8f1fe25726c6bb19be-8095-4a3d-81af-6e8f1fe25726c6bb19be80954a3d81af6e8f1fe25726{c6bb19be-8095-4a3d-81af-6e8f1fe25726}(c6bb19be-8095-4a3d-81af-6e8f1fe25726){0xc6bb19be,0x8095,0x4a3d,{0x81,0xaf,0x6e,0x8f,0x1f,0xe2,0x57,0x26}}三、字符串转换为Guid字符串转换为Guid的两种常⽤⽅式:以下⼏种字符串都⾏。

序列号g开头的是什么

序列号g开头的是什么

序列号g开头的是什么
序列号以G开头的通常是指全球唯一标识符(GUID)。

GUID是一种由算法生成的,长达128位的数字标识符,它在计算机系统中被广泛使用,以确保在全球范围内的唯一性。

GUID是一种非常有用的标识符,可以用于许多不同的应用程序中。

下面是一些常见的应用场景:
1. 在数据库中,GUID可以用作主键,确保每个记录都具有唯一的识别码。

2. 在操作系统中,GUID可以用于创建唯一的文件名,确保文件不会被覆盖或重复。

3. 在网络应用程序中,GUID可以用于跟踪用户会话,从而帮助应用程序保持状态。

4. 在多人协作应用程序中,如源代码管理系统,GUID可用于标识每个提交版本,确保每个版本都具有唯一的标识符。

除了上述应用场景外,GUID还可以用于任何需要唯一标识符的情况。

比如,在游戏中,每个玩家可以用一个GUID来标识他们的账户。


移动应用程序中,GUID可以用于标识不同的设备,并将数据同步到云端。

总的来说,GUID是一种非常有用的标识符,可以帮助各种类型的应用
程序确保唯一性。

在实际使用中,您可以使用各种工具来生成GUID,或者手动创建自己的GUID。

无论您如何使用它们,GUID都是一个非
常有用的工具,可以帮助您确保数据的唯一性和安全性。

C#中GUID--全球标识符的使用

C#中GUID--全球标识符的使用
3、Guid.NewGuid().ToString("B") 结果为:
{09f140d5-af72-44ba-a763-c861304b46f8}
4、Guid.NewGuid().ToString("P") 结果为:
(778406c2-efff-4262-ab03-70a77d09c2b5)
string guid = Guid.NewGuid().ToString();
// Add parameters
db.AddInParameter(dbCommand, "Log_guid", DbType.String, guid);
db.AddInParameter(dbCommand, "Log_Title", DbType.String, model.Log_Title);
strSql.Append("Insert into cs_Content(");
strSql.Append("Log_guid, Log_Title, Log_Content, Log_PostTime, Log_ViewNums)");
strSql.Append(" values (");
guid的每段位数:8+4+4+4+12
-------------------
GUID重复的可能性几乎为0,可放心使用,重复的机率比碰鬼的机率还小,在不同的机器上如此,在同一台机器上重复的机率更是几乎不可能
使用C#Guid.NewGuid()生成的GUID长度为36位
这一篇文章将解释.NET框架如何尽其最大潜力地为你建立自己的GUID。

单片机全球唯一id的设计原理

单片机全球唯一id的设计原理

单片机全球唯一id的设计原理
单片机全球唯一ID的设计原理是基于全球唯一标识符(GUID)或UUID。

这些ID是随机生成的,具有极低的重复概率,因此可以保证全球范围内的
唯一性。

UUID是一种128位的数字标识符,通常由32个十六进制数字组成,并按
照的格式分成五部分,例如:32位的厂商ID、16位的硬件序列号、8位的版本号、4位的日期和时间信息以及12位的随机数。

通过这种方式,UUID 可以确保在全世界的唯一性。

在单片机中,全球唯一ID通常被存储在一个非易失性的存储器中,例如ROM或者EEPROM。

当单片机启动或复位时,程序会读取这个ID并验证
其有效性。

如果ID损坏或丢失,则单片机可以通过预设的备份ID进行恢复。

这种设计原理可以防止单片机被克隆或复制,从而保护产品的知识产权和安全性。

同时,全球唯一ID还可以用于跟踪和记录单片机的生产、使用和维
修情况,有助于提高产品的可追溯性和质量控制。

guid生成原理

guid生成原理

guid生成原理
GUID(全球唯一标识符)是一个128位的数字标识符,通常用于在计算机系统中唯一标识对象。

GUID的生成原理是基于网络上全球唯一性的概念,也就是说,它的产生机制无法确保完全唯一,但是由于其长度以及十六进制表示,使得重复的概率非常小。

通常GUID是基于以下几个要素组成:
1. MAC地址:网络接口的物理地址或者独特的硬件ID。

2. 时间戳:当前的时间戳作为一个初始值。

3. 随机数:生成更高的随机性,并保证多个生成请求同时产生唯一标识符。

生成GUID的算法是将MAC地址和时间戳通过特定的算法合并,并加入随机数,生成一个唯一的标识符。

这个算法处理之后会生成一个统一资源定位符(URL)形式的GUID字符串,例如:{3F2504E0-4F89-11D3-9A0C-0305E82C3301}。

GUID常用于数据库表的主键、文件的唯一标识、Web应用程序中的会话标识等。

guid的组成

guid的组成

guid的组成GUID(全局唯一标识符)是一种由计算机系统生成的标识符,用于唯一标识对象或实体。

它由一串数字和字母组成,通常呈现为32个字符的十六进制数。

GUID的组成是由多个因素决定的,下面将详细介绍。

首先,GUID的组成包括时间戳。

时间戳是指GUID生成的时间,通常以自1970年1月1日以来的毫秒数表示。

时间戳确保了GUID的唯一性,因为每个时间戳都是不同的,这样就避免了重复生成相同的GUID。

其次,GUID的组成还包括计算机的唯一标识符。

计算机的唯一标识符是指计算机硬件或操作系统生成的一个唯一的标识符,用于区分不同的计算机。

这个标识符通常是根据计算机的硬件信息或操作系统的特征生成的,确保了在不同的计算机上生成的GUID也是唯一的。

另外,GUID的组成还包括一个随机数。

随机数是指在生成GUID 时,计算机系统会生成一个随机的数值,用于增加GUID的随机性和唯一性。

随机数的引入使得即使在同一时间戳和计算机标识符下,生成的GUID也是不同的。

最后,GUID的组成还包括一个校验位。

校验位是指在生成GUID 时,计算机系统会根据前面的组成部分计算出一个校验值,用于验证GUID的正确性。

校验位的引入可以确保生成的GUID没有错误或损坏,提高了GUID的可靠性。

综上所述,GUID的组成包括时间戳、计算机的唯一标识符、随机数和校验位。

这些因素的综合作用使得生成的GUID具有全局唯一性和随机性,可以在计算机系统中广泛应用于唯一标识对象或实体的需求。

GUID的组成保证了生成的标识符不会重复,同时也提高了标识符的可靠性和安全性。

在现代计算机系统中,GUID已经成为一种重要的标识符生成方式,被广泛应用于各种领域,如数据库管理、分布式系统等。

GUID详解

GUID详解

在USB编程之前要事先了解一下GUID的概念。

应用其他网页中的定义:全球唯一标识符(GUID) 是一个字母数字标识符,用于指示产品的唯一性安装。

在许多流行软件应用程序(例如Web 浏览器和媒体播放器)中,都使用GUID。

GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中每个x 是0-9 或a-f 范围内的一个十六进制的数字。

例如:6F9619FF-8B86-D011-B42D-00C04FC964FF 即为有效的GUID 值。

在计算机领域有很多东西需要不重复的唯一标识的东西,例如设备的类型,类,接口标识,目录名等等。

这是个天文数字,我记得是有工具能自动生成这个GUID码的,反正不同地点,不同时间,生成相同的GUID的可能性很小很小很小,小到什么程度,没查过,基本上可以认为是不可能生成相同的GUID值的。

计算机中有各种个样的设备类型,这些设备类型被微软用固定的GUID来标识了,这些GUID 对实际编程是有很大关系的,用错了会麻烦,我查了一下文档,把查到的设备类型的GUID 列在下面供大家参考:1394 Host Bus ControllerClass = 1394ClassGuid = {6bdd1fc1-810f-11d0-bec7-08002be2092f}This class includes system-supplied drivers of 1394 host controllers connected on a PCI bus, but not drivers of 1394 peripherals.Battery DevicesClass = BatteryClassGuid = {72631e54-78a4-11d0-bcf7-00aa00b7b32a}This class includes drivers of battery devices and UPSes.CD-ROM DrivesClass = CDROMClassGuid = {4d36e965-e325-11ce-bfc1-08002be10318}This class includes drivers of CD-ROM drives, including SCSI CD-ROM drives. By default, the system's CD-ROM class installer also installs a system-supplied CD audio driver and CD-ROM changer driver as PnP filters.Disk DrivesClass = DiskDriveClassGuid = {4d36e967-e325-11ce-bfc1-08002be10318}This class includes drivers of hard disk drives. See also the HDC and SCSIAdapter classes.Display AdaptersClass = DisplayClassGuid = {4d36e968-e325-11ce-bfc1-08002be10318}This class includes drivers of video adapters, including display drivers and video miniports.Floppy Disk ControllersClass = FDCClassGuid = {4d36e969-e325-11ce-bfc1-08002be10318}This class includes drivers of floppy disk drive controllers.Floppy Disk DrivesClass= FloppyDiskClassGuid= {4d36e980-e325-11ce-bfc1-08002be10318}This class includes drivers of floppy drives.Hard Disk ControllersClass = HDCClassGuid = {4d36e96a-e325-11ce-bfc1-08002be10318}This class includes drivers of hard disk controllers, including ATA/ATAPI controllers but not SCSI and RAID disk controllers.Human Input Devices (HID)Class = HIDClassClassGuid = {745a17a0-74d3-11d0-b6fe-00a0c90f57da}This class includes devices that export interfaces of the HID class, including HID keyboard and mouse devices, which the installed HID device drivers enumerate as their respective "child" devices. (See also the Keyboard or Mouse classes later in this list.)Imaging DeviceClass = ImageClassGuid = {6bdd1fc6-810f-11d0-bec7-08002be2092f}This class includes drivers of still-image capture devices, digital cameras, and scanners.IrDA DevicesClass = InfraredClassGuid = {6bdd1fc5-810f-11d0-bec7-08002be2092f}This class includes Serial-IR and Fast-IR NDIS miniports, but see also the Network Adapter class for other NDIS NIC miniports.KeyboardClass = KeyboardClassGuid = {4d36e96b-e325-11ce-bfc1-08002be10318}This class includes all keyboards. That is, it also must be specified in the (secondary) INF for an enumerated "child" HID keyboard device.Medium ChangersClass= MediumChangerClassGuid= {ce5939ae-ebde-11d0-b181-0000f8753ec4}This class includes drivers of SCSI media changer devices.Memory Technology DriverClass = MTDClassGUID = {4d36e970-e325-11ce-bfc1-08002be10318}This class includes drivers for memory devices, such as flash memory cards.MultimediaClass = MediaClassGuid = {4d36e96c-e325-11ce-bfc1-08002be10318}This class includes Audio and DVD multimedia devices, joystick ports, and full-motion video-capture devices.ModemClass = ModemClassGuid = {4d36e96d-e325-11ce-bfc1-08002be10318}This class installs modems. An INF for a device of this class installs no device driver(s), but rather specifies the features and configuration information of a particular modem and stores this information in the registry. See also the Multifunction class.MonitorClass = MonitorClassGuid = {4d36e96e-e325-11ce-bfc1-08002be10318}This class includes display monitors. An INF for a device of this class installs no device driver(s), but rather specifies the features of a particular monitor to be stored in the registry for use by drivers of video adapters. (Monitors are enumerated as the child devices of display adapters.)MouseClass = MouseClassGuid = {4d36e96f-e325-11ce-bfc1-08002be10318}This class includes all mice and other kinds of pointing devices, such as trackballs. That is, it also must be specified in the (secondary) INF for an enumerated "child" HID mouse device.Multifunction DevicesClass = MultifunctionClassGuid = {4d36e971-e325-11ce-bfc1-08002be10318}This class includes combo cards, such as a PCMCIA modem and netcard adapter. The driver for such a PnP multifunction device is installed under this class and enumerates the modem and netcard separately as its "child" devices.Multi-port Serial AdaptersClass = MultiportSerialClassGuid = {50906cb8-ba12-11d1-bf5d-0000f805f530}This class includes intelligent multiport serial cards, but not peripheral devices that connect to its ports. It does not include unintelligent (16550-type) mutiport serial controllers or single-port serial controllers (see the Ports class).Network AdapterClass = NetClassGuid = {4d36e972-e325-11ce-bfc1-08002be10318}This class includes NDIS NIC miniports excluding Fast-IR miniports, NDIS intermediate drivers (of "virtual adapters"), and CoNDIS MCM miniports.Network ClientClass = NetClientClassGuid = {4d36e973-e325-11ce-bfc1-08002be10318}This class includes network and/or print providers.Network ServiceClass = NetServiceClassGuid = {4d36e974-e325-11ce-bfc1-08002be10318}This class includes network services, such as redirectors and servers.Network TransportClass = NetTransClassGuid = {4d36e975-e325-11ce-bfc1-08002be10318}This class includes NDIS protocols, CoNDIS stand-alone call managers, and CoNDIS clients, as well as higher level drivers in transport stacks.PCMCIA AdaptersClass = PCMCIAClassGuid = {4d36e977-e325-11ce-bfc1-08002be10318}This class includes system-supplied drivers of PCMCIA and CardBus host controllers, but not drivers of PCMCIA or CardBus peripherals.Ports (COM & LPT serial ports)Class = PortsClassGuid = {4d36e978-e325-11ce-bfc1-08002be10318}This class includes drivers of serial or parallel port devices, but see also the MultiportSerial class.PrinterClass = PrinterClassGuid = {4d36e979-e325-11ce-bfc1-08002be10318}This class includes printers.SCSI and RAID ControllersClass = SCSIAdapterClassGuid = {4d36e97b-e325-11ce-bfc1-08002be10318}This class includes SCSI HBA miniports and disk-array controller drivers.Smart Card ReadersClass = SmartCardReaderClassGuid = {50dd5230-ba8a-11d1-bf5d-0000f805f530}This class includes drivers for smart card readers.Storage VolumesClass = V olumeClassGuid = {71a27cdd-812a-11d0-bec7-08002be2092f}This class includes storage volumes as defined by the system-supplied logical volume manager and class drivers that create device objects to represent storage volumes, such as the system disk class driver.System DevicesClass = SystemClassGuid = {4d36e97d-e325-11ce-bfc1-08002be10318}This class includes the Windows® 2000 HALs, system bus drivers, the system ACPI driver, and the system volume-manager driver. It also includes battery drivers and UPS drivers.Tape DrivesClass = TapeDriveClassGuid = {6d807884-7d21-11cf-801c-08002be10318}This class includes drivers of tape drives, including all tape miniclass drivers.USBClass = USBClassGuid = {36fc9e60-c465-11cf-8056-444553540000}This class includes system-supplied (bus) drivers of USB host controllers and drivers of USB hubs, but not drivers of USB peripherals.The following classes and GUIDs should not be used to install devices (or drivers) on Windows 2000 platforms:AdapterClass = AdapterClassGUID = {4d36e964-e325-11ce-bfc1-08002be10318}This class is obsolete.APMClass = APMSupportClassGUID = {d45b1c18-c8fa-11d1-9f77-0000f805f530}This class is reserved for system use.ComputerClass = ComputerClassGUID = {4d36e966-e325-11ce-bfc1-08002be10318}This class is reserved for system use.DecodersClass = DecoderClassGUID = {6bdd1fc2-810f-11d0-bec7-08002be2092f}This class is reserved for future use.Global Positioning SystemClass = GPSClassGUID = {6bdd1fc3-810f-11d0-bec7-08002be2092f}This class is reserved for future use.No driverClass = NoDriverClassGUID = {4d36e976-e325-11ce-bfc1-08002be10318}This class is obsolete.Non-Plug and Play DriversClass = LegacyDriverClassGUID = {8ecc055d-047f-11d1-a537-0000f8753ed1}This class is reserved for system use.Other DevicesClass = UnknownClassGUID = {4d36e97e-e325-11ce-bfc1-08002be10318}This class is reserved for system use. Enumerated devices for which the system cannot determine the type are installed under this class. Do not use this class if you're unsure in which class your device belongs; either determine the correct device setup class or create a new class.Printer UpgradeClass = Printer UpgradeClassGUID = {4d36e97a-e325-11ce-bfc1-08002be10318}This class is reserved for system use.SoundClass = SoundClassGUID = {4d36e97c-e325-11ce-bfc1-08002be10318}This class is obsolete.USB Mass Storage DeviceClassGUID = a5dcbf10-6530-11d2-901f-00c04fb951ed。

gis中guid数据类型

gis中guid数据类型

gis中guid数据类型英文回答:GUID Data Type in GIS.GUID (Globally Unique Identifier) is a data type thatis used to represent a unique identifier for a feature in a GIS system. GUIDs are typically 128-bit values that are generated using a random number generator. They are often used to identify features that are created in different systems or that are stored in different databases.GUIDs have several advantages over other types ofunique identifiers. First, they are guaranteed to be unique, even if they are generated by different systems. Second, they are relatively short, which makes them easy to store and transmit. Third, they are easy to generate, which makes them suitable for use in large-scale systems.However, GUIDs also have some disadvantages. First,they are not human-readable, which can make it difficult to identify features in a database. Second, they can be difficult to compare, which can make it difficult to perform certain types of queries.Alternatives to GUIDs.There are several alternatives to GUIDs that can be used to represent unique identifiers in a GIS system. These include:Integer IDs: Integer IDs are simple numbers that are used to identify features. They are often auto-generated by the database system. Integer IDs are easy to generate and compare, but they are not guaranteed to be unique.String IDs: String IDs are text strings that are used to identify features. They are often assigned by the user. String IDs are easy to read and understand, but they are not guaranteed to be unique.Composite IDs: Composite IDs are combinations of twoor more fields that are used to identify features. They are often used to represent relationships between features. Composite IDs are guaranteed to be unique, but they can be more difficult to generate and compare than other types of unique identifiers.The best choice for a unique identifier in a GIS system will depend on the specific requirements of the application.中文回答:GIS 中的 GUID 数据类型。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

GUID概念GUID:即Globally Unique Identifier(全球唯一标识符)也称作UUID(Universally Unique IDentifier) 。

GUID是一个通过特定算法产生的二进制长度为128位的数字标识符,用于指示产品的唯一性。

GUID 主要用于在拥有多个节点、多台计算机的网络或系统中,分配必须具有唯一性的标识符。

在 Windows 平台上,GUID 广泛应用于微软的产品中,用于标识如如注册表项、类及接口标识、数据库、系统目录等对象。

GUID格式GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中每个x 是 0-9 或 a-f 范围内的一个32位十六进制数。

(8-4-4-4-12)例如:6F9619FF-8B86-D011-B42D-00C04FC964FF 即为有效的 GUID 值。

GUID特点★GUID在空间上和时间上具有唯一性,保证同一时间不同地方产生的数字不同。

★世界上的任何两台计算机都不会生成重复的 GUID 值。

★需要GUID的时候,可以完全由算法自动生成,不需要一个权威机构来管理。

★GUID的长度固定,并且相对而言较短小,非常适合于排序、标识和存储。

GUID争议由于GUID值产生的潜在弊端已经引起了保密性提倡者的关注。

1999年3月,美国联邦商务委员会接到要求,对微软的GUID值使用进行调查。

争议主要涉及Office 97和Office 2000文档对GUID值的使用。

Office文档,如Word文件或Excel电子数据表,所使用的GUID值对用户是不可见的。

但有很多报道宣称,文档的作者是可以通过GUID值的跟踪查到的,即使作者已经采用特殊方法,他们还是可以被追踪到。

为了回应上述问题,微软已经发布了一个Office 97修补版SR2,它禁止了GUID功能的使用,并且还可以将现存文档的GUID去除。

潜在的对Intel处理器序列号滥用的问题与上述GUID值的问题本质是一样的。

在 API 参数中,需要给出的往往不是类或者 DLL/EXE 文件的真是名称,而是使用他们的 GUID(全局统一ID)。

GUID 是微软对 UUID(统一唯一标识)的解释,理论上在整个空间和时间维上是唯一的,因此使用 GUID 来代替真实名称,可以防止系统中有两个相同名称的对象而造成混淆。

一个GUID 是一个128位长(16字节)的数,形如xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx。

其中前4字节为随机数;5-8字节为时间戳,记录了从1490年开始到该GUID的生成时间(低16位字在前,以分钟为单位),从而保证了时间上的唯一;9-10字节与机器重启次数有关;最后6字节一般为该机器的网卡地址(如果这台机器没有网卡,则使用另一常数),从而保证了空间上的唯一。

在系统中,GUID 保存在注册表(运行→regedit)的HKEY_CLASSES_ROOT 项下。

HKEY_CLASSES_ROOT 其实是HKEY_LOCAL_MACHINE\SOFTWARE\CLASSES\ 的快捷键,里面有很多长长的字串命名的子项,这些字串就是 GUID。

在 HKEY_CLASSES_ROOT 下的 GUID 又分为4部分:程序ID:如 Access.Application 等,其中 Access 表示类所在 DLL/EXE 文件名,Application 是类的名称。

虽然程序ID较类ID易用,但因为它并不一定是唯一的,因此可能造成混乱。

在 VB 和 VJ++ 中程序员只能使用程序ID,不过这两种语言允许程序ID长达39个字符,因此完全可以取一个与GUID 完全相同的程序ID,从而保证程序ID也是唯一的。

CLSID:在这个子键下列出了在机器上注册过的所有类ID。

在每个GUID 键下。

可以找到所有关于这个类ID的信息。

如果该类ID对应一个DLL,则DLL文件名在 InprocServer32 子键下;如果是本地的一个EXE程序,则文件名在 LocalServer32 子键下;如果是远程EXE,则有一个 AppID 子键指向 AppID 键的入口。

AppID:在这个子键下列出了每个远程 DLL/EXE 的启动参数,包括对象位置、文件名等。

Interface:在这个子键下列出了本地系统中所有注册过的类的 GUID。

在其中每个 GUID 键下,都保存着代理的类ID,当其他应用程序要与它通信时就使用这个ID传入传出参数。

GUID(全局统一标识符)是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的。

通常平台会提供生成GUID的API。

生成算法很有意思,用到了以太网卡地址、纳秒级时间、芯片ID码和许多可能的数字。

GUID的唯一缺陷在于生成的结果串会比较大。

”1. 一个GUID为一个128位的整数(16字节),在使用唯一标识符的情况下,你可以在所有计算机和网络之间使用这一整数。

2. GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中每个x 是0-9 或a-f 范围内的一个十六进制的数字。

例如:337c7f2b-7a34-4f50-9141-bab9e6478cc8 即为有效的GUID 值。

3. 世界上任何两台计算机都不会生成重复的GUID 值。

GUID 主要用于在拥有多个节点、多台计算机的网络或系统中,分配必须具有唯一性的标识符。

4. 在Windows 平台上,GUID 应用非常广泛:注册表、类及接口标识、数据库、甚至自动生成的机器名、目录名等。

·.NET中使用GUID当Windows开发人员需要一个唯一数值时,他们通常使用到一个全局唯一标识符(GUID, Globally Unique Identifier)。

微软采用GUID术语来表示这一唯一数值,而这一数值能够标识一个实体,比如一个Word文档。

一个GUID为一个128位的整数(16字节),在使用唯一标识符的情况下,你可以在所有计算机和网络之间使用这一整数。

这一篇文章将解释.NET框架如何尽其最大潜力地为你建立自己的GUID。

你所看到的GUIDs被用于整个Windows环境。

当你在一个Windows系统中仔细阅读注册表时,你可以看到GUIDs被广泛用于唯一识别程序。

特别地,它们作为程序的Ids集中在HKEY_CLASSES_ROOT部分(AppID键)。

这就是一个典型的GUID的格式:936DA01F-9ABD-4d9d-80C7-02AF85C822A8在.NET中生成一个GUID处理一个唯一标识符使得存储和获得信息变得更加容易。

在处理一个数据库中这一功能变得尤其有用,因为一个GUID能够操作一个主键。

同样,SQL Server也很好地集成了GUID的用途。

SQL Server数据类型uniqueidentifier 能够存储一个GUID数值。

你可以通过使用NEWID()函数在SQL Server中生成这一数值,或者可以在SQL Server之外生成GUID,然后再手动地插入这一数值。

在.NET中,后面一种方法显得更加直接。

.NET Framework中的基本System类包括GUID数值类型。

除此之外,这一数值类型包含了处理GUID数值的方法。

特别地,NewGUID 方法允许你很容易地生成一个新的GUID。

以下的C#命令行程序说明这一使用过程:using System;namespace DisplayGUID {class GuidExample {static void Main(string[] args) {Console.WriteLine("GUID: " + System.Guid.NewGuid().ToString());}} }下面为这一程序的输出:(虽然不同系统之间的GUID是变化的。

)GUID: 9245fe4a-d402-451c-b9ed-9c1a04247482在这一点上,你可以看到GUID是一个很好的功能,但在程序的什么地方使用到它们,并如何使用它们?在程序中使用一个GUID一个GUID可以在后台数据库中操作一个主键。

以下代码使用一个GUID在一个后台数据库中存储信息,这一数据库包含以下的列:pk_guid—uniqueidentifier数据类型name—nvarchar数据类型这样出现一个包含文本框的简单Windows窗体。

当选择按钮时,文本框中的数据被插入到数据库中。

通过程序代码可以生成一个GUID并存储在其它列中:StringBuilder strSql = new StringBuilder();strSql.Append("Insert into cs_Content(");strSql.Append("Log_guid, Log_Title, Log_Content, Log_PostTime, Log_ViewNums)");strSql.Append(" values (");strSql.Append("@Log_guid, @Log_Title, @Log_Content, @Log_PostTime, @Log_ViewNums)");DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());string guid = Guid.NewGuid().ToString();// Add parametersdb.AddInParameter(dbCommand, "Log_guid", DbType.String, guid);db.AddInParameter(dbCommand, "Log_Title", DbType.String, model.Log_Title);db.AddInParameter(dbCommand, "Log_Content", DbType.String, model.Log_Content);db.AddInParameter(dbCommand, "Log_PostTime", DbType.DateTime, model.Log_PostTime);db.AddInParameter(dbCommand, "Log_ViewNums", DbType.Int32, model.Log_ViewNums);int res = db.ExecuteNonQuery(dbCommand);另一个GUID程序将一个唯一的标识符分配给一个.NET类或者接口,也就是说,GUID 作为一个属性被分配给类或者接口。

相关文档
最新文档