我正在尝试创建一个C#inproc服务器sbtsv.idl(它包含在Windows 8 SDK中).我找到的几乎所有指令都会告诉您使用MIDL创建.tlb文件然后tlbimport创建代理dll.
但是,如果IDL不包含某个library部分,则不会生成任何.tlb文件,sbtsv.idl也不包含library部分.
我尝试创建自己的IDL文件,声明我想在库中创建的接口
#include "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\sbtsv.idl"
[uuid(43250D0C-BBC6-4109-BCD2-6F61F0D3B611)]
library sbtsvClientLib
{
interface ITsSbResourceNotification;
};
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行它时,MIDL我得到以下错误
Microsoft (R) 32b/64b MIDL Compiler Version 8.00.0603 Copyright (c) Microsoft Corporation. All rights reserved. Processing .\sbtsvClientLib.idl sbtsvClientLib.idl Processing C:\Program Files (x86)\Windows Kits\8.1\include\um\oaidl.idl oaidl.idl Processing C:\Program Files (x86)\Windows Kits\8.1\include\um\objidl.idl objidl.idl Processing C:\Program Files (x86)\Windows Kits\8.1\include\um\unknwn.idl unknwn.idl Processing C:\Program …
我的任务是将旧的VB6程序转换为C#.我无法移植的一个功能是从二进制文件中读取的字段计算出生日期:
.BirthDate = CDate((CLng(recPatient.birthDateByte2) * 256) +
(recPatient.birthDateByte1 + 366))
Run Code Online (Sandbox Code Playgroud)
我能找到的唯一一个远程类似的功能是:
DateTime BirthDate = DateTime.ToDateTime((long)recPatient.birthDateByte2) * 256)
+ (recPatient.birthDateByte1 + 366));
Run Code Online (Sandbox Code Playgroud)
然而,ToDateTime(long)只是返回一个InvalidCastException.
现在我可以手动构建字符串,但我无法在VB6上的任何地方找到任何文档CDate(long).
我究竟做错了什么?
我有一个Sql数据库(我无法控制架构),它有一个将具有varchar值为"是","否"的列,或者它将为null.出于我正在做的目的,null将被处理为否.
我使用数据表和表适配器在c#net 3.5中编程来提取数据.我想使用绑定源将列直接绑定到我的程序中的复选框但是我不知道如何或在何处将逻辑转换为字符串Yes/No/null为布尔值True/False;
从SQL Server读取null并在更新上写回No是可接受的行为.
任何帮助是极大的赞赏.
编辑 - 这是为Windows开发的.
注入x64-process的x64-DLL挂钩x86-DLL,无法使用C++和EasyHook.如果Loader,InjectionLibrary和InjectionTarget(它在两个版本中都可用并且我需要两者都被挂钩)都是x86的话.获取导出过程的地址(GetProcAddress本身)在x64上不是问题.InjectionTarget还有HookTarget(Kernel32.dll)作为x64的依赖项.LhInstallHook(...)返回STATUS_NOT_SUPPORTED,其中源注释表示在以下情况下发生:"目标入口点包含不受支持的指令."
由于x86版本的源代码很好,我决定不添加它.
我抓了一个小图

我有一个应用程序,当您单击一个按钮时,它会打开SharePoint共享上的文件.在IE中,它将正确地打开文档,如果您对文件进行更改,它会将更改推送回SharePoint服务器,但是如果用户将Firefox作为其默认浏览器,则Firefox将首先下载文件,然后使用本地副本.有没有办法强制程序在IE中打开链接而不是默认浏览器(或直接使用Word,但是我需要在访问文件之前传递用户域凭据)?
BackgroundWorker bw = new BackgroundWorker();
GeneratingChecklist frmProgressBar = new GeneratingChecklist();
frmProgressBar.Show();
bw.DoWork += (sender, e) =>
{
e.Result = Build(AccountNumber, PracticeName, ContractID, EducationDate, MainContactInfo, Address);
};
bw.RunWorkerCompleted += (sender, e) =>
{
frmProgressBar.Close();
running = false;
if (e.Result != null)
{
System.Diagnostics.Process.Start(((FileDetails)e.Result).Address);
}
else
{
MessageBox.Show("An error occurred generating or retrieving the educator checklist.");
}
};
bw.RunWorkerAsync();
Run Code Online (Sandbox Code Playgroud)
FileDetails.Address 禁止word文档的URL.
我试图找到所有不以幻数 开头的图像ff d8 ff e0(jpg的签名)根据MSDN,我应该可以在我的数据上使用patindex.然而
SELECT TOP 1000 [cpclid]
FROM [cp]
where patindex('FFD8FFE0%', cpphoto) = 0 -- cpphoto is a column type of image
Run Code Online (Sandbox Code Playgroud)
给了我错误
消息8116,级别16,状态1,行1参数数据类型图像对于patindex函数的参数2无效.
找到与幻数不匹配的记录的正确方法是ff d8 ff e0什么?
更新:
我罗斯的解决方案最终通过对查询的调整进行了一些调整.
SELECT [cpclid]
FROM [cp]
where convert(varchar(max), cast(cpphoto as varbinary(max))) not like convert(varchar(max), 0xFFD8FFE0 ) + '%'
Run Code Online (Sandbox Code Playgroud)
我找到了更好的解决方案,请参阅我的回答.
我在我的应用程序有两种形式MainForm和HexCompare.如果我点击我的应用程序到另一个窗口然后我点击两个表单中的一个,只有其中一个来到前面.如果我单击两个表单中的任何一个表单,它将如何使其成为应用程序中所有打开表单的顶部?现在我需要单独选择每个表单以使它们到我的窗口堆栈的顶部(这可能非常烦人,因为HexCompare已经ShowInTaskbar设置为false
一个很好的例子就是我想要的方式是大多数查找对话框的工作方式.如果单击查找对话框,则如果主窗体被另一个应用程序隐藏,则它会将主窗体带到前面;如果单击主窗体,则如果另一个应用程序隐藏了查找对话框,则它将出现在前面.
如何MainForm调用.
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
Run Code Online (Sandbox Code Playgroud)
如何HexCompare调用
private void lstCaputres_SelectedIndexChanged(object sender, EventArgs e)
{
var selectedItem = (Tuple<DateTime, byte[]>)lstCaputres.SelectedItem;
if (hexCompare == null || hexCompare.IsDisposed)
{
hexCompare = new HexCompare(selectedItem.Item2);
hexCompare.Show();
}
else
hexCompare.ChangeValue(selectedItem.Item2);
}
Run Code Online (Sandbox Code Playgroud)
编辑:
似乎HexCompare价值Parent是Null.如果我能以某种方式设置它来MainForm解决我的问题,如果是这样我该怎么设置它?
EDIT2:
我已经使用Tigran的解决方案对其进行了半解决,但是如果有更好的解决方案我仍然感兴趣,它会导致闪烁,因为每个表单都会被带到前面.
//In MainForm.cs
private void MainForm_Activated(object sender, EventArgs e)
{
hexCompare.BringToFront();
this.BringToFront();
}
//in …Run Code Online (Sandbox Code Playgroud) 如果我想调用Directory.GetFiles并让它返回所有匹配模式的文件,*.bin但我想排除所有匹配模式的文件,LOG#.bin其中#是一个不确定长度的运行计数器.有没有办法在传入搜索过滤器的步骤中过滤掉结果,GetFiles或者我必须获取结果数组然后删除我要排除的项目?
编辑:我想我问了一些XY问题.我并不真正关心让隧道事件工作,我关心的是从父窗口后面的代码中获取一个事件来获取并通过一个控件来响应,该控件是该窗口的子控件而无需明确需要告诉孩子其父母是谁并手动订阅该事件.
我试图在父控件中引发一个事件,并让子控件监听该事件并对其做出反应.根据我的研究,我认为我只需要做一个RoutedEvent但是我做错了.
这是一个显示我尝试过的MCVE,它是一个带有窗口和UserControl的简单程序.
<Window x:Class="RoutedEventsTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:RoutedEventsTest"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Name="button" Click="ButtonBase_OnClick" HorizontalAlignment="Left"
VerticalAlignment="Top">Unhandled in parent</Button>
<local:ChildControl Grid.Row="1"/>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
using System.Windows;
namespace RoutedEventsTest
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
TestEventHandler += MainWindow_TestEventHandler;
}
void MainWindow_TestEventHandler(object sender, RoutedEventArgs e)
{
button.Content = "Handeled in parent";
e.Handled = false;
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
RaiseEvent(new RoutedEventArgs(TestEvent));
}
public static …Run Code Online (Sandbox Code Playgroud) 我试图在我的C#代码中包含以下行,但由于某种原因,它被标记为错误:
public SynchronizedCollection<Uri> allImages = new SynchronizedCollection<Uri>();
Run Code Online (Sandbox Code Playgroud)
我试过包括,using System.Collections.Generic但它没有解决问题.知道如何SynchronizedCollection<T>在我的应用程序中工作吗?