相关疑难解决方法(0)

QCroreApplication QApplication与WMI

我在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)

c++ wmi qt

7
推荐指数
1
解决办法
4637
查看次数

Qt:无法在C#上初始化OLE(错误80010106)-(libwkhtmltox.dll)

即时通讯使用此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)

关于上面的代码:

  • content =我要转换为pdf的html内容。
  • fullPath =将在其中存储html内容。
  • _projectSettingsOptions =项目的路径,例如图像路径,pdf路径等...

然后,我调用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)

c# wkhtmltopdf asp.net-core-mvc

7
推荐指数
1
解决办法
2495
查看次数

标签 统计

asp.net-core-mvc ×1

c# ×1

c++ ×1

qt ×1

wkhtmltopdf ×1

wmi ×1