我有一个较旧的应用程序(约2005年)接受DLL插件.该应用程序最初是为Win32 C插件设计的,但我有一个有效的C#dll模板.我的问题:我需要做一些一次性初始化,在Win32 C dll中将在DllMain中完成:
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
[one-time stuff here...]
}
Run Code Online (Sandbox Code Playgroud)
有没有C#相当于此?我拥有的C#模板中没有"DllMain".我尝试了一个文字C#解释,但没有去:dll工作,但它不会触发DllMain函数.
public static bool DllMain(int hModule, int reason, IntPtr lpReserved) {
[one time stuff here...]
}
Run Code Online (Sandbox Code Playgroud) 在VS2008中,我为C#dll设计了一个表单.这个dll是一个较旧的应用程序的插件(大约2005年):我们称之为"OldApp".在VS表单设计器中,我的表单上的Label控件中的文本很好地呈现:antialiased和kerned.但是当我在OldApp(C#dll作为插件运行)中调出此表单时,Label控件中的文本看起来很难看.它很清晰,但字距很差:字母间距更远,看似随机偏移.我可以做些什么来使OldApp中的文本标签看起来像在VS的表单设计器中一样好?我怀疑具体字体是否重要,但它是Arial,7.2 pt(默认为VS2008).我尝试使用Program.cs中的两个相关行(见下文),但没有效果.
Application.EnableVisualStyles(); // tried using it and commenting it out
Application.SetCompatibleTextRenderingDefault(true); // tried true and false
Run Code Online (Sandbox Code Playgroud) 使用像"HorsieDoggieBirdie"这样的字符串,是否有一个非捕获正则表达式替换会杀死"Horsie"和"Birdie",但保持"Doggie"完好无损?我只能想到一个捕获解决方案:
s/(Horsie)(Doggie)(Birdie)/$2/g
Run Code Online (Sandbox Code Playgroud)
是否有非捕获解决方案,如:
s/Horsie##Doggie##Birdie//g
Run Code Online (Sandbox Code Playgroud)
其中##是正则表达式代码的一些组合?具体问题在JavaScript(innerHTML.replace)中,但我也会采用Perl建议.