我在MSDN网站上找到了一些WMI C++应用程序示例.
我已经尝试了以下链接的代码
http://msdn.microsoft.com/en-us/library/aa390423%28v=VS.85%29.aspx
当我复制并运行应用程序作为win32控制台应用程序时它运作良好.
与Qt应用程序相同的代码,
当我使用QApplication anApplication(argc,argv); 在我的代码中,它无法正常工作
但是,如果我使用QCroreApplication anApplication(argc,argv); 这是工作
向我显示错误,如"当我将QCroreApplication更改为QApplication时,下面的源代码不起作用,并给我错误,如"无法初始化COM库.错误代码= 0x80010106"
任何建议或帮助
#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <comdef.h>
#include <Wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
// Qt Includes
#include <QtCore>
#include <QtGui>
//----------------------------------------------------------------------------
// Main Function
int main( int a_argc, char *a_argv[] )
//************************************
{
// initialize the application
QApplication anapplication( a_argc, a_argv );
HRESULT hres;
// Step 1: --------------------------------------------------
// Initialize COM. ------------------------------------------
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
cout << "Failed to …Run Code Online (Sandbox Code Playgroud) 即时通讯使用此libwkhtmltox.dll将我的html转换为pdf。我正在使用c#.netCore。
用法:
private static string CreatePdf(string content, string fileName)
{
var fullPath = $"{_projectSettingsOptions.Pdf}/{fileName}";
using (var sw = new StreamWriter(new FileStream(fullPath, FileMode.Create), Encoding.UTF8))
{
sw.Write(content);
sw.Flush();
}
new Pdf(_projectSettingsOptions).Convert(fullPath, content);
return fullPath;
}
Run Code Online (Sandbox Code Playgroud)
关于上面的代码:
然后,我调用Pdf类,传递要转换的路径和内容。
new Pdf(_projectSettingsOptions).Convert(fullPath, content);
Run Code Online (Sandbox Code Playgroud)
这是我的Pdf课:
namespace SiteMFPManager.Library.Util
{
using Assembly;
using DinkToPdf;
using Settings;
using System.IO;
public class Pdf
{
public Pdf(ProjectSettingsOptions projectSettingsOptions) =>
new CustomAssemblyLoadContext().LoadUnmanagedLibrary(Path.Combine(projectSettingsOptions.References, "libwkhtmltox", "libwkhtmltox.dll"));
public void Convert(string fullPath, string content) =>
new SynchronizedConverter(new PdfTools()).Convert(new HtmlToPdfDocument
{ …Run Code Online (Sandbox Code Playgroud)