---
title: "向 Windows 添加许可密钥 | ComPDF PDF SDK (Windows)"
canonical_url: "https://www.compdf.com/zh-cn/guides/pdf-sdk/windows/apply-the-license-key"
md_url: "https://www.compdf.com/zh-cn/guides/pdf-sdk/windows/apply-the-license-key.md"
description: "向 Windows 添加许可密钥 — ComPDF PDF SDK (Windows). 如果您还没有获取许可证密钥，请查看如何获取许可证密钥。"
---

# 向 Windows 添加许可密钥

如果您还没有获取许可证密钥，请查看[如何获取许可证密钥](https://www.compdf.com/zh-cn/guides/pdf-sdk/windows/requirements)。

ComPDF PDF SDK 目前支持两种许可证密钥验证方式：在线认证和离线认证。

_了解关于：_

-   [_ComPDFKit的许可证认证机制是什么？_](https://www.compdf.com/faq/authentication-mechanism-of-compdfkit-license)
    
-   [_在线认证和离线认证有什么区别？_](https://www.compdf.com/faq/the-differences-between-online-authentication-and-offline-authentication)
    

## 复制许可证密钥

正确获取许可证密钥，是许可证应用的关键。

1.  在您收到的邮件中，找到包含许可证密钥的`XML`文件
    
2.  复制许可证密钥的`XML`文件到您自己的项目。
    

## 应用许可证密钥

您可以通过以下方式进行认证：

```C#
public static bool LicenseVerify()
{
	if (!CPDFSDKVerifier.LoadNativeLibrary())
	{ 
		return false;
	}
    string xmlPath = "您的许可证密钥 XML 文件的路径";
	LicenseErrorCode status = CPDFSDKVerifier.LicenseVerify(xmlPath);
	return status == LicenseErrorCode.E_LICENSE_SUCCESS;
}
```
