有没有办法确定文件是否被任何包含未锁定文件的应用程序(如记事本)打开.
我需要检测给定文件myfile.txt何时不再在包括记事本在内的任何应用程序中打开 - 所以我不能使用具有独占访问权限的File.Open(...)来测试,因为文件没有锁定.
我正在测试以下示例代码,并且每当我尝试运行它时,我将在下面显示错误.但是,calc.exe进程是成功执行的,那么句柄如何可能为null或为零?我希望你能理解我想要解决的问题.谢谢!代码示例来自http://www.mathpirate.net/log/tag/system-windows-automation/
UIAutomationClient.dll中发生未处理的"System.ArgumentException"类型异常附加信息:hwnd不能是IntPtr.Zero或null.
//Launches the Windows Calculator and gets the Main Window's Handle.
Process calculatorProcess = Process.Start("calc.exe");
calculatorProcess.WaitForInputIdle();
IntPtr calculatorWindowHandle = calculatorProcess.MainWindowHandle;
//Here I use a window handle to get an AutomationElement for a specific window.
AutomationElement calculatorElement = AutomationElement.FromHandle(calculatorWindowHandle);
if(calculatorElement == null)
{
throw new Exception("Uh-oh, couldn't find the calculator...");
}
//Walks some of the more interesting properties on the AutomationElement.
Console.WriteLine("--------Element");
Console.WriteLine("AutomationId: {0}", calculatorElement.Current.AutomationId);
Console.WriteLine("Name: {0}", calculatorElement.Current.Name);
Console.WriteLine("ClassName: {0}", calculatorElement.Current.ClassName);
Console.WriteLine("ControlType: {0}", calculatorElement.Current.ControlType.ProgrammaticName);
Console.WriteLine("IsEnabled: {0}", calculatorElement.Current.IsEnabled);
Console.WriteLine("IsOffscreen: {0}", …Run Code Online (Sandbox Code Playgroud) 我想知道是否有一种方法可以让Spy ++获得一个窗口的属性,当它失去焦点时会自动关闭(这是我切换到Spy ++时会发生的事情).谢谢!
我有一些关于endian-ness的问题已经足够相关,我保证将它们作为一个问题加入:
1)字节是由.Net还是由硬件决定的?
2)如果由硬件决定,我怎样才能弄清楚硬件在C#中的端点?
3)endian-ness是否影响二进制交互,如OR,AND,XOR或移位?IE将向右移动一次总是偏离最不重要的位?
4)我对此表示怀疑,但不同版本的.Net框架的字节序有何不同?我假设他们都是一样的,但我已经学会停止假设一些较低级别的细节,比如这个.
如果需要,我可以问这些不同的问题,但我认为任何知道其中一个答案的人可能都知道所有人的答案(或者可以指出我的方向).
我想检测用户何时点击链接iframe并更改其来源iframe,因为我想调整它的大小.我也使用jQuery.检测此问题的最佳方法是什么?
实际上我需要这样的东西(这个例子在jQuery中,它不起作用,我想象这个)
$('#iframe').live('load', function(){ alert('src is changed')});
Run Code Online (Sandbox Code Playgroud) 如何在Visual C++中故意创建一个编译器警告(在#error模型中,除了作为警告),它将在错误列表中显示正确的文件和行号?
GCC和其他编译器提供#warning,但MSVC编译器没有.
http://support.microsoft.com/kb/155196上的"解决方案" 未在Visual Studio错误列表中进行解析.
c++ compiler-construction pragma compiler-warnings visual-studio
好的,这是我的程序中的一个方法,它一直给出EXC_BAD_ACCESS错误并崩溃.我在下面说明了这一行.questionsShown是一个readwrite属性,指向一个NSMutableArray,我在程序的早期点初始化容量为99.当我调试时,就所分配的属性而言,所有内容都显得正常.我认为内存管理一定存在问题,但我在查找问题时遇到了严重问题.在此先感谢您的帮助.
@synthesize questionList;
@synthesize questionLabel;
@synthesize questionsShown;
-(IBAction)next{
int numElements = [questionList count];
int r;
if (myCount == numElements){
[questionLabel setText:@"You have seen all the questions, click next again to continue anyways."];
[questionsShown release];
questionsShown = [[NSMutableArray alloc] initWithCapacity:99];
myCount = 0;
}
else {
do {
r = rand() % numElements;
} while ([questionsShown indexOfObjectIdenticalTo:r] != NSNotFound);
NSString *myString = [questionList objectAtIndex:(NSUInteger)r];
[questionLabel setText:myString];
myCount++;
[questionsShown addObject:r]; //results in crash with message EXC_BAD_ACCESS
myCount++;
}
}
Run Code Online (Sandbox Code Playgroud) 如何检查SD卡是否已满,以便您的应用程序可以决定是否可以继续执行其工作,即写入外部存储器或通知用户存储空间不足.
我正在学习如何在我们的Intranet中使用外部XML提要,以更好地为我们的员工服务,并减少他们走出网络以获取内容的需求.
我可以毫无问题地从Feed中呈现基本信息.我来的地方是试图显示一个视频缩略图,作为我选择的布局的一部分.
问题
我试图URL从第一个media:thumbnail元素中获取属性的值以用于img标记,但无论我尝试什么,我似乎无法呈现它的内容.
例如;
<media:thumbnail url='http://i.ytimg.com/vi/CQP_AuT4zXQ/default.jpg'... />
我要从上面的例子中提取和使用的文本是 http://i.ytimg.com/vi/CQP_AuT4zXQ/default.jpg
我怀疑为什么我无法解析这个元素的值与其中有句点(:)分隔符的元素名称有关,和/或我对jQuery的开发知识怀疑我没有调用或试图正确解析此元素或其中的一部分.
我也想渲染它的价值media:keywords,这可以通过理解同一个问题来解决.
用于呈现XML的代码
<script type="text/javascript">
/* learned from http://www.switchonthecode.com/tutorials/xml-parsing-with-jquery */
/* this can be used to parse any file in an XML format */
$(document).ready(function()
{
/*
perform an asynchronous ajax request using the relevant variables
Documentation: http://api.jquery.com/jQuery.ajax/
*/
$.ajax({
type: "GET",
/* define url of xml file to parse */
url: "/pr/rss_repository/youtube.xml",
/* assign it a data type */
dataType: "xml", …Run Code Online (Sandbox Code Playgroud) preg_match_all("/[^A-Za-z0-9]/",$new_password,$out);
Run Code Online (Sandbox Code Playgroud)
以上只检查第一个字符,如何检查是否都是字母数字?
c# ×3
jquery ×2
android ×1
automation ×1
c++ ×1
endianness ×1
file-io ×1
html ×1
iframe ×1
iphone ×1
javascript ×1
objective-c ×1
php ×1
pragma ×1
spy++ ×1
string ×1
windows ×1
xml ×1
youtube-api ×1