PowerPoint - 如何以编程方式确定演示文稿是否有密码?

时间:2021-03-21 13:02:58

I'm writing an application that processes PowerPoint presentations and I'm looking into ways of detecting whether or not a PowerPoint presentation has a password if it does then stop processing it.

我正在编写一个处理PowerPoint演示文稿的应用程序,我正在研究检测PowerPoint演示文稿是否有密码的方法,如果它然后停止处理它。

3 个解决方案

#1


3  

It seems to me that there is no way to check if the presentation is password-protected. You have to open the document first to make properties accessible. You have to provide the password when you are opening the document.

在我看来,没有办法检查演示文稿是否受密码保护。您必须先打开文档才能访问属性。打开文档时必须提供密码。

There is a Password Property you can check.

您可以检查密码属性。

I've found a workaround on Expert Exchange:

我在Expert Exchange上找到了一个解决方法:

The problem is the following: Visual Basic is a single threaded application, this means that you cant put a certain procedure on hold and proceed with another (in the same application). When powerpoint has an "on open"-password set, the CreateObject procedure inside your application is put on hold untill powerpoint releases it, this is when the user types in a password. There is no way around this that I know off, but you can make a workaround:

问题如下:Visual Basic是一个单线程应用程序,这意味着您不能保持某个过程并继续使用另一个(在同一个应用程序中)。当powerpoint具有“on open”-password集时,应用程序内的CreateObject过程将被置于保持状态,直到powerpoint释放它,这是用户输入密码的时间。我不知道这件事,但你可以解决这个问题:

Make 2 applications, 1 application is the application you already have, the second one is a "powerpoint unlocker". You run the second program just before you open the protected powerpoint presentation in application 1. You can do that with the shell command. The "powerpoint unlocker" can be as advanced as you want it to be, you can for example provide command line parameters to specify which presentation must be unlocked with what password. Then you use the findwindow api to get the window handle of the locked presentation. Once you have that, you use the sendmessage api to input the password. After this the "powerpoint unlocker" unloads and the first application can resume with its excution.

制作2个应用程序,1个应用程序是您已经拥有的应用程序,第二个应用程序是“powerpoint unlocker”。您在应用程序1中打开受​​保护的powerpoint演示文稿之前运行第二个程序。您可以使用shell命令执行此操作。 “powerpoint unlocker”可以像您希望的那样高级,例如,您可以提供命令行参数来指定必须使用什么密码解锁哪个演示文稿。然后使用findwindow api获取锁定演示文稿的窗口句柄。完成后,使用sendmessage api输入密码。在此之后,“powerpoint unlocker”卸载并且第一个应用程序可以在其执行时恢复。

I hope this helps!

我希望这有帮助!

Osmodean

#2


1  

Consider looking at this - http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx

考虑一下这个 - http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx

For a PPTX document, you can examine the first 8 bytes to look at the header (should be [d0cf 11e0 a1b1 1ae1] for an encrypted file), and know if it is an encrypted PPTX or not.

对于PPTX文档,您可以检查前8个字节以查看标题(对于加密文件应该是[d0cf 11e0 a1b1 1ae1]),并知道它是否是加密的PPTX。

However, for files created with Office 2003 (default extension .ppt), the header is the same (MS-CFB header). So, if somebody creates an office 2003 document and then renames it to a PPTX, your code will consider it as an encrypted document (whereas, it wouldn't necessarily be one).

但是,对于使用Office 2003(默认扩展名.ppt)创建的文件,标头是相同的(MS-CFB标头)。因此,如果某人创建了Office 2003文档,然后将其重命名为PPTX,则您的代码会将其视为加密文档(而不一定是一个)。

If you are working with documents already opened in Powerpoint, you can use the SaveCopyAs function to first save the document to disk in the pptx format (use the default option in the second parameter), and then examine the header to check if it's an encrypted file.

如果您正在处理已在Powerpoint中打开的文档,则可以使用SaveCopyAs函数首先以pptx格式将文档保存到磁盘(使用第二个参数中的默认选项),然后检查标题以检查它是否已加密文件。

#3


0  

Consider looking at this - https://msdn.microsoft.com/ko-kr/library/dd948895(v=office.12).aspx

考虑一下这个 - https://msdn.microsoft.com/ko-kr/library/dd948895(v=office.12).aspx

For a PPT(office 2003) document, you can examine the unsigned integer(0xF3D1C4DF bits) to identify whether the file is encrypted.

对于PPT(office 2003)文档,您可以检查无符号整数(0xF3D1C4DF位)以确定文件是否已加密。

#1


3  

It seems to me that there is no way to check if the presentation is password-protected. You have to open the document first to make properties accessible. You have to provide the password when you are opening the document.

在我看来,没有办法检查演示文稿是否受密码保护。您必须先打开文档才能访问属性。打开文档时必须提供密码。

There is a Password Property you can check.

您可以检查密码属性。

I've found a workaround on Expert Exchange:

我在Expert Exchange上找到了一个解决方法:

The problem is the following: Visual Basic is a single threaded application, this means that you cant put a certain procedure on hold and proceed with another (in the same application). When powerpoint has an "on open"-password set, the CreateObject procedure inside your application is put on hold untill powerpoint releases it, this is when the user types in a password. There is no way around this that I know off, but you can make a workaround:

问题如下:Visual Basic是一个单线程应用程序,这意味着您不能保持某个过程并继续使用另一个(在同一个应用程序中)。当powerpoint具有“on open”-password集时,应用程序内的CreateObject过程将被置于保持状态,直到powerpoint释放它,这是用户输入密码的时间。我不知道这件事,但你可以解决这个问题:

Make 2 applications, 1 application is the application you already have, the second one is a "powerpoint unlocker". You run the second program just before you open the protected powerpoint presentation in application 1. You can do that with the shell command. The "powerpoint unlocker" can be as advanced as you want it to be, you can for example provide command line parameters to specify which presentation must be unlocked with what password. Then you use the findwindow api to get the window handle of the locked presentation. Once you have that, you use the sendmessage api to input the password. After this the "powerpoint unlocker" unloads and the first application can resume with its excution.

制作2个应用程序,1个应用程序是您已经拥有的应用程序,第二个应用程序是“powerpoint unlocker”。您在应用程序1中打开受​​保护的powerpoint演示文稿之前运行第二个程序。您可以使用shell命令执行此操作。 “powerpoint unlocker”可以像您希望的那样高级,例如,您可以提供命令行参数来指定必须使用什么密码解锁哪个演示文稿。然后使用findwindow api获取锁定演示文稿的窗口句柄。完成后,使用sendmessage api输入密码。在此之后,“powerpoint unlocker”卸载并且第一个应用程序可以在其执行时恢复。

I hope this helps!

我希望这有帮助!

Osmodean

#2


1  

Consider looking at this - http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx

考虑一下这个 - http://blogs.msdn.com/b/openspecification/archive/2009/07/17/overview-of-protected-office-open-xml-documents.aspx

For a PPTX document, you can examine the first 8 bytes to look at the header (should be [d0cf 11e0 a1b1 1ae1] for an encrypted file), and know if it is an encrypted PPTX or not.

对于PPTX文档,您可以检查前8个字节以查看标题(对于加密文件应该是[d0cf 11e0 a1b1 1ae1]),并知道它是否是加密的PPTX。

However, for files created with Office 2003 (default extension .ppt), the header is the same (MS-CFB header). So, if somebody creates an office 2003 document and then renames it to a PPTX, your code will consider it as an encrypted document (whereas, it wouldn't necessarily be one).

但是,对于使用Office 2003(默认扩展名.ppt)创建的文件,标头是相同的(MS-CFB标头)。因此,如果某人创建了Office 2003文档,然后将其重命名为PPTX,则您的代码会将其视为加密文档(而不一定是一个)。

If you are working with documents already opened in Powerpoint, you can use the SaveCopyAs function to first save the document to disk in the pptx format (use the default option in the second parameter), and then examine the header to check if it's an encrypted file.

如果您正在处理已在Powerpoint中打开的文档,则可以使用SaveCopyAs函数首先以pptx格式将文档保存到磁盘(使用第二个参数中的默认选项),然后检查标题以检查它是否已加密文件。

#3


0  

Consider looking at this - https://msdn.microsoft.com/ko-kr/library/dd948895(v=office.12).aspx

考虑一下这个 - https://msdn.microsoft.com/ko-kr/library/dd948895(v=office.12).aspx

For a PPT(office 2003) document, you can examine the unsigned integer(0xF3D1C4DF bits) to identify whether the file is encrypted.

对于PPT(office 2003)文档,您可以检查无符号整数(0xF3D1C4DF位)以确定文件是否已加密。