小编spi*_*orm的帖子

使用cpp文件中的#pragma指定延迟加载dll

我有一个静态链接库,它使用我需要延迟加载的dll中的一些函数.所以在我的可执行文件属性中,我添加了这个dll Linker/Input/Delay Loaded DLLs.我不能在lib本身中添加这个选项,因为它没有Linker属性页面(因为它是一个静态库)
所以现在每当我在另一个可执行工具中使用这个lib时,我需要一遍又一遍地添加延迟加载选项再次,我想避免.我知道这曾经是一个实用主义者

#pragma comment(linker, "/DELAYLOAD:mydll.dll")
Run Code Online (Sandbox Code Playgroud)

然而,它对我不起作用,因为它说

warning LNK4229: invalid directive '/DELAYLOAD:mydll.dll' encountered; ignored
Run Code Online (Sandbox Code Playgroud)

除了LoadLibrary之外,还有出路吗?

c++ visual-studio

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

c ++数组语法(函数返回数组)

为什么这段代码需要数组语法中的'&'?

int (&returnArray(int (&arr)[42]))[42]
{
  return arr;
}
Run Code Online (Sandbox Code Playgroud)

当我宣布这样的时候

int (returnArray(int arr[42]))[42]
{
  return arr;
}
Run Code Online (Sandbox Code Playgroud)

我明白了

error C2090: function returns array
Run Code Online (Sandbox Code Playgroud)

但这不是第一个例子中返回的数组吗?它是某种对数组的引用吗?

我知道我也可以将一个数组传递给一个函数,它会衰减到一个指针

int returnInt(int arr[42])
{
  return arr[0];
}
Run Code Online (Sandbox Code Playgroud)

或通过引用传递它

int returnInt(int (&arr)[42])
{
  return arr[0];
}
Run Code Online (Sandbox Code Playgroud)

但为什么我不能以相同的方式返回数组?

c++ arrays

5
推荐指数
1
解决办法
1238
查看次数

SetDllDirectory失败并带有一些unicode符号

我正在使用SetDllDirectory(实际上是SetDllDirectoryW)来从特定目录加载一些延迟加载的库.
它就像

if (SetDllDirectory(directory.c_str()) == 0)
{
    ERROR_MSG("Failed to set the current dll directory [%d]\n", GetLastError());
}
Run Code Online (Sandbox Code Playgroud)

所以一切正常,大部分时间"f:/source/trunk 11"都很好,等等.
但是当它被调用时"f:/source/trunk Gest hieß es !?;%()_@#$^&",我ERROR_INVALID_PARAMETER从GetLastError 得到.我能够创建一个具有这样名称的目录,我可以使用它.
但有什么特别的SetDllDirectory"Gest hieß es !?;%()_@#$^&"?我该如何解决?

c++ unicode winapi

4
推荐指数
1
解决办法
294
查看次数

标签 统计

c++ ×3

arrays ×1

unicode ×1

visual-studio ×1

winapi ×1