我有一个C sharp控制台应用程序,可以多次捕获MS Word文档的屏幕截图.它工作得很好,但是当我将这个应用程序放在一个远程的Windows XP机器上它工作正常,我远程桌面是可见的,但如果我运行我的应用程序并离开远程桌面(最小化,甚至没有注销我想要做的)截图是空白的!
屏幕截图应用程序由作为SYSTEM用户运行的服务运行.
即使没有连接用户,如何让GUI保持活动状态?
这是我使用的代码:
public Image CaptureWindow(IntPtr handle)
{
// get te hDC of the target window
IntPtr hdcSrc = User32.GetWindowDC(handle);
// get the size
User32.RECT windowRect = new User32.RECT();
User32.GetWindowRect(handle, ref windowRect);
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
// create a device context we can copy to
IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
// create a bitmap we can copy it to,
// using GetDeviceCaps to get the width/height
IntPtr …Run Code Online (Sandbox Code Playgroud) 为什么我用下面的高度和宽度为0:
static void Main(string[] args)
{
Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.Start();
IntPtr handle = notePad.Handle;
RECT windowRect = new RECT();
GetWindowRect(handle, ref windowRect);
int width = windowRect.Right - windowRect.Left;
int height = windowRect.Bottom - windowRect.Top;
Console.WriteLine("Height: " + height + ", Width: " + width);
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
这是我对GetWindowRect的定义:
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
Run Code Online (Sandbox Code Playgroud)
这是我对RECT的定义:
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left; // x position of upper-left corner
public int …Run Code Online (Sandbox Code Playgroud) 我需要一些实施建议.我有一个MYSQL数据库,它将被远程写入以便在本地处理任务,我需要用PHP编写的应用程序,以便在进入时执行这些任务.
但当然我的PHP应用程序需要被告知何时运行.我想过使用cron作业,但我的应用程序是在Windows机器上.其次,我需要每隔几秒钟不断检查一次,而cron只能每分钟检查一次.
我想过编写一个PHP守护进程,但我正在接受它的工作,如果它甚至是一个好主意!
我很感激有关最佳方法的任何建议.
换行符号\n当我尝试检测并替换它时会给我带来一些麻烦:这很好用:
String x = "Bob was a bob \\n";
String y = x.replaceAll("was", "bob");
System.out.println(y);
Run Code Online (Sandbox Code Playgroud)
但是这段代码没有给出理想的结果
String x = "Bob was a bob \\n";
String y = x.replaceAll("\n", "bob");
System.out.println(y);
Run Code Online (Sandbox Code Playgroud) 我的讲师没有为我们提供教程的.java文件.我的问题是,如何在我的eclipse项目中使用他的类文件,并击败以下错误?
错误:
Exception in thread "main" java.lang.NoClassDefFoundError: lec/utils/InputReader
at randomIt.main(randomIt.java:17)
Caused by: java.lang.ClassNotFoundException: lec.utils.InputReader
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import java.util.Random;
import lec/utils.InputReader;
public class randomIt {
public static void main(String[] args) {
Random generator = new Random();
InputReader myReader = new InputReader();
//Pick a number randomly between 1 and 10!
int number = generator.nextInt(10)+1;
//Ask user to guess...!
System.out.println("Take a guess (1 …Run Code Online (Sandbox Code Playgroud) char x [1000];
x = 'hello';
.....
clear contents of x???
Run Code Online (Sandbox Code Playgroud)
我会用什么来清除x?我无法重新初始化它,使用strcpy(x,'/ 0')或free().
什么是strncpyC++中的等价物?strncpy在C中工作,但在C++中失败.
这是我正在尝试的代码:
string str1 = "hello";
string str2;
strncpy (str2,str1,5);
Run Code Online (Sandbox Code Playgroud) 如何根据其包含的字符串获取元素ID?
<span id="th67">This the string I need to match</span>
Run Code Online (Sandbox Code Playgroud)
我无法使用JQuery或任何其他Javascript库来执行此操作.
我需要这样做进行硒测试.
没有我的图书馆,我没有意识到我在JS中是多么无用!
谢谢大家的帮助.
public class MaxHeap<T extends Comparable<T>> implements Heap<T>{
private T[] heap;
private int lastIndex;
private static final int defaultInitialCapacity = 25;
public void add(T newItem) throws HeapException{
if (lastIndex < Max_Heap){
heap[lastIndex] = newItem;
int place = lastIndex;
int parent = (place – 1)/2; //ERROR HERE**********
while ( (parent >=0) && (heap[place].compareTo(heap[parent])>0)){
T temp = heap[place];
heap[place] = heap[parent];
heap[parent] = temp;
place = parent;
parent = (place-1)/2;
}else {
throw new HeapException("HeapException: Heap full"); }
}
}
Run Code Online (Sandbox Code Playgroud)
Eclipse抱怨说有一个:
"Syntax error …
#include <stdio.h>
int main(void){
char x [] = "hello world.";
printf("%s \n", &x[0]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
打印出上面的代码 "hello world."
我怎么打印出来的"h"?访问不应该x[0]确保这一点吗?
在下面的程序中,我将变量设置th为true第二个if语句中的变量.我很好奇为什么它后来又回来了false.
public boolean nodeExist(TreeNode Tree, T value){
boolean th = false;
if(Tree.getValue()!= null){
if(value == Tree.getValue()){
th = true;
}else{
if(value.compareTo((T) Tree.getValue()) < 0){
nodeExist(Tree.getLeft(), value);
}else{
nodeExist(Tree.getRight(), value);
}
}
}else{
th = false;
}
return th;
}
Run Code Online (Sandbox Code Playgroud)