假设我有以下 WIX 标记,指示 MSI 安装程序从包含的 DLL 调用自定义操作:
<CustomAction Id="CA_SetProperties_Finalize"
Property="CA_OnInstallFinalize"
Value="[Installed],[REINSTALL],[UPGRADINGPRODUCTCODE],[REMOVE]" />
<CustomAction Id='CA_OnInstallFinalize'
BinaryKey='CADll'
DllEntry='msiOnInstallFinalize'
Execute='deferred' Impersonate='no' />
<InstallExecuteSequence>
<Custom Action='CA_SetProperties_Finalize'
Before='InstallFinalize'></Custom>
<Custom Action='CA_OnInstallFinalize'
After='CA_SetProperties_Finalize'></Custom>
</InstallExecuteSequence>
<Binary Id='CADll' SourceFile='Sources\ca-installer.dll' />
Run Code Online (Sandbox Code Playgroud)
DLL 本身具有以下用于自定义操作的 C++ 代码:
<CustomAction Id="CA_SetProperties_Finalize"
Property="CA_OnInstallFinalize"
Value="[Installed],[REINSTALL],[UPGRADINGPRODUCTCODE],[REMOVE]" />
<CustomAction Id='CA_OnInstallFinalize'
BinaryKey='CADll'
DllEntry='msiOnInstallFinalize'
Execute='deferred' Impersonate='no' />
<InstallExecuteSequence>
<Custom Action='CA_SetProperties_Finalize'
Before='InstallFinalize'></Custom>
<Custom Action='CA_OnInstallFinalize'
After='CA_SetProperties_Finalize'></Custom>
</InstallExecuteSequence>
<Binary Id='CADll' SourceFile='Sources\ca-installer.dll' />
Run Code Online (Sandbox Code Playgroud)
发生的情况是,当我的doWork方法失败时,安装不应继续,因此我返回ERROR_INSTALL_FAILURE。问题是,在这种情况下,安装程序会直接退出,安装 GUI 窗口也会消失。
所以我很好奇,是否有任何方法可以更改 Wix 标记,以便在我的自定义操作返回错误时能够显示用户消息?
对于C ++代码中的异常处理程序,我需要以下内容。说,我有以下代码块:
void myFunction(LPCTSTR pStr, int ncbNumCharsInStr)
{
__try
{
//Do work with 'pStr'
}
__except(1)
{
//Catch all
//But here I need to log `pStr` into event log
//For that I don't want to raise another exception
//if memory block of size `ncbNumCharsInStr` * sizeof(TCHAR)
//pointed by 'pStr' is unreadable.
if(memory_readable(pStr, ncbNumCharsInStr * sizeof(TCHAR)))
{
Log(L"Failed processing: %s", pStr);
}
else
{
Log(L"String at 0x%X, %d chars long is unreadable!", pStr, ncbNumCharsInStr);
}
}
}
Run Code Online (Sandbox Code Playgroud)
有什么办法可以实施memory_readable?
我正在尝试在 VS 2010 的 C# WinForms 项目中编译这个简单的代码:
using System.IO;
using System.IO.Compression;
string zipPath = @"c:\example\start.zip";
string extractPath = @"c:\example\extract";
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
{
entry.ExtractToFile(Path.Combine(extractPath, entry.FullName));
}
}
}
Run Code Online (Sandbox Code Playgroud)
ZipFile 类的描述告诉我需要添加System.IO.Compression.FileSystem程序集。抱歉问这个问题,但到底是哪里呢?它是作为 DLL 来的吗?它不在 .NET 参考列表中,我确信我已经安装了 .NET Framework v.4.5。
编辑:无论谁想在你的 VS 2010 项目中包含一个简单的 Zip 存档支持,我发现这个项目可以直接编译到你自己的项目中。非常干净和简单。
我正在使用Visual Studio 2008 for Windows编译以下内容.
当我声明一个全局数组时:
//.cpp file
// on a global scale
// (i.e. outside any class definition)
MY_ITEM glob_arr[1024];
Run Code Online (Sandbox Code Playgroud)
哪里
//.h file
extern MY_ITEM glob_arr[1024];
class MyClass
{
public:
MyClass()
{
//Start using glob_arr
glob_arr[0].v = 0;
//...
}
};
Run Code Online (Sandbox Code Playgroud)
和
struct MY_ITEM{
int v;
WCHAR chrs[64];
};
Run Code Online (Sandbox Code Playgroud)
在哪里glob_arr分配 - 从堆栈或进程堆?
让我用下面的C++/MFC代码解释一下我的意思:
static CString MyFormat(LPCTSTR pszFormat, ...)
{
CString s;
va_list argList;
va_start( argList, pszFormat );
s.FormatV(pszFormat, argList);
va_end( argList );
return s;
}
static CString MyFormat2(int arg1, LPCTSTR pszFormat, ...)
{
if(arg1 == 1)
{
//How to call MyFormat() from here?
return MyFormat(pszFormat, ...); //???
}
//Do other processing ...
}
Run Code Online (Sandbox Code Playgroud)
我如何MyFormat()从内部打电话MyFormat2()?
我正在审查一个最初由另一个开发人员编写的旧ASP经典代码.我一直在看<%=标签.谁能告诉我它叫什么?它做了什么?
PS.谷歌搜索<%=似乎不起作用.
我正在编写一个MFC应用程序,它需要允许垂直窗口调整大小并防止水平调整大小.最简单的方法是什么?
我似乎无法在MSDN中找到答案.我很好奇,如果我有这样的事情:
LPITEMIDLIST pidl = NULL;
HRESULT hr = SHParseDisplayName(L"\\\\?\\C:\\Users\\Name\\Folder", NULL, &pidl, 0, NULL);
Run Code Online (Sandbox Code Playgroud)
它HRESULT设置为失败E_INVALIDARG.如果我提供路径"C:\\Users\\Name\\Folder",那么问题就会消失,因为路径仅限于MAX_PATH字符.
这些Shell API与长Unicode路径不兼容吗?
如果我阅读PostMessage API 的描述,它有这句话:
系统仅对系统消息进行编组(范围为0到(WM_USER-1)).要将其他消息(那些> = WM_USER)发送到另一个进程,您必须执行自定义编组.
我很好奇那个"消息编组"是什么?
为什么如下:
GetFileAttributes(L"D:");
Run Code Online (Sandbox Code Playgroud)
返回0x00002010,但在完全相同的机器上的以下内容:
GetFileAttributes(L"\\\\?\\D:");
Run Code Online (Sandbox Code Playgroud)
返回INVALID_FILE_ATTRIBUTES和错误代码ERROR_INVALID_PARAMETER?