【发布时间】:2019-11-08 17:04:37
【问题描述】:
我正在尝试将 user32.dll 放入我的统一免费版本。 (非专业)
我只是将 user32.dll 放到了我的 Assets/Plugins/ 文件夹中,它给我的错误是:
DLLNotFoundException: Assets/Plugins/user32.dll
这是我正在使用的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;
public class DatabaseManager : MonoBehaviour
{
//DLL imports
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
static Process proc = Process.GetProcessesByName("firefox")[0];
IntPtr ptrFF = proc.Handle;
//------------------------------------------------------------------------
void Awake()
{
SetForegroundWindow(ptrFF);
}
//Other code functions like Update etc.
}
我在某处听说非托管 dll (c++) 只能在 Unity Pro 中使用,但我真的需要这个 DLL,我是不是做的不准确???我不确定 user32.dll 是否真的属于非托管 c++ dll。
请帮忙。
【问题讨论】:
-
什么 Unity 版本?什么构建平台?
-
Unity 2019.3.0a6 构建平台只是PC、Mac和Linux Standalone,目标平台是Windows Architecture x86_64
-
最近几天经常这样说^^
2019.3.0a6是一个Alpha版本..它充满了错误和错误并不少见..那是alpha 版本的整个想法。对于生产来说,它不稳定。也许首先尝试回到最新的稳定版本2019.1.8并检查它是否在那里工作......然后也许看看NativePlugins Manual -
@derHugo 可能与它是非托管 dll 有关吗?还是 C++ 代码?
-
@derHugo 我降级到 2019.1.8f1,我会告诉你发生了什么。