C++ ile VBA Kodunun Dijital İmza Geçerliğini Kontrol Edin
Contents
[
Hide
]
Aspose.Cells, VBA kodunun dijital imzasının geçerliliğini Workbook.VbaProject.IsValidSigned özelliği kullanarak kontrol etmenizi sağlar. İmza geçerliyse true, değilse false döner. VBA kodu değiştirildiğinde dijital imza geçersiz hale gelir.
C++ ile VBA Kodunun Dijital İmzasının Geçerli olup olmadığını Kontrol Edin
Aşağıdaki kod, sağlanan bağlantıdan indirilebilir örnek excel dosyasıyla kullanımını gösterir. Aynı Excel dosyasının geçerli bir imzası vardır, fakat VBA kodunu değiştirdiğimizde ve çalışma kitabını kaydettiğimizde, imzası geçersiz hale gelir.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Load the workbook from an existing Excel file with VBA project
Workbook workbook(srcDir + u"sampleVBAProjectSigned.xlsm");
// Check if the VBA Code Project is valid signed
std::cout << "Is VBA Code Project Valid Signed: " << (workbook.GetVbaProject().IsValidSigned() ? "True" : "False") << std::endl;
// Modify the VBA Code
U16String code = workbook.GetVbaProject().GetModules().Get(1).GetCodes();
code = u"Welcome to Aspose.Cells"; // Directly setting new code here
workbook.GetVbaProject().GetModules().Get(1).SetCodes(code);
// Save the workbook
workbook.Save(srcDir + u"output_out.xlsm");
// Reload the workbook
workbook = Workbook(srcDir + u"output_out.xlsm");
// Now the signature is invalid
std::cout << "Is VBA Code Project Valid Signed: " << (workbook.GetVbaProject().IsValidSigned() ? "True" : "False") << std::endl;
Aspose::Cells::Cleanup();
}