在客户端Web应用程序中,我想:
我希望用户能够获得流畅的体验,并通过连接到BeforeClose事件来检测他们何时完成excel,但我发现我无法在javascript/HTML中连接到Excel的事件.
function BeforeCloseEventHandler(cancel) {
// TODO: read values from spreadsheet
alert("Closing...");
}
function openExcel() {
var excel = new ActiveXObject("Excel.Application");
var workbook = excel.Workbooks.Add();
var worksheet = workbook.Worksheets(1);
worksheet.Cells(1, 1).Value = "First Cell";
worksheet.Cells(1, 2).Value = "Second Cell";
workbook.BeforeClose = BeforeCloseEventHandler; // THIS DOESN'T WORK
excel.Visible = true;
excel.UserControl = true;
}
Run Code Online (Sandbox Code Playgroud)
有没有人有什么建议?
我在嵌入式环境(Arduino/AVR ATMega328)中工作,并希望在C++中实现Factory Method模式.但是,我正在使用的编译器(avr-gcc)不支持该new关键字.有没有办法在不使用的情况下实现这种模式new?
我有兴趣在我的Vista机器上将DLL注入到SYSTEM拥有的进程中.我正在使用VirtualAllocEx,WriteProcessMemory和CreateRemoteThread的传统方法.但是,因为这将在SYSTEM进程上运行,所以我在打开目标进程之前在注入进程上启用SeDebugPivilege.
int EnableDebugPriv(LPCTSTR name) {
HANDLE hToken;
LUID luid;
TOKEN_PRIVILEGES tkp;
if(!OpenProcessToken(GetCurrentProcess(),
/*TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY*/
TOKEN_ALL_ACCESS,
&hToken))
return 0;
if(!LookupPrivilegeValue(NULL,name,&luid))
return 0;
tkp.PrivilegeCount=1;
tkp.Privileges[0].Luid=luid;
tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
if(!AdjustTokenPrivileges(hToken,false,&tkp,sizeof(tkp),NULL,NULL))
{
printf("!AdjustTokenPrivileges - %d\n",GetLastError());
return 0;
}
if(GetLastError()==ERROR_NOT_ALL_ASSIGNED)
{
return 0;
}
CloseHandle(hToken);
return 1;
}
Run Code Online (Sandbox Code Playgroud)
当SE_DEBUG_NAME常数为名称传递.
启用SeDebugPrivilege之后,我将完成打开目标进程,查找LoadLibrary,分配空间,将DLL路径写入内存以及创建线程(检查所有返回值)的过程:
if(NULL==(p=OpenProcess(PROCESS_ALL_ACCESS,FALSE,(DWORD)pid)))
...
if(NULL==(loadLib=(LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"),
"LoadLibraryA")))
...
if(NULL==(dllBuff=(LPVOID)VirtualAllocEx(p,
NULL,
strlen(dllPath)+1,
MEM_RESERVE|MEM_COMMIT,
PAGE_READWRITE)))
...
if(NULL==WriteProcessMemory(p,
(LPVOID)dllBuff,
dllPath,
strlen(dllPath),
&written))
...
if(!CreateRemoteThread(p,
NULL,
NULL,
(LPTHREAD_START_ROUTINE)loadLib,
(LPVOID)dllBuff,
NULL,
NULL))
...
Run Code Online (Sandbox Code Playgroud)
dllPath是DLL路径的char*(显然),pid是目标进程的PID.这两个值都通过命令行获取并在使用前进行验证.
我遇到的问题是,在CreateRemoteThread返回8("存储空间不足")之前,没有任何东西会返回错误.但是,WriteProcessMemory不会向进程写入任何字节.在调用之后,写入的变量始终为0.没有写入字节,但函数没有失败.我不确定为什么会这样.我查看了其他权限,比如SeRestorePrivilege,它承诺对所有进程进行写访问,但没有任何效果.
我正在使用管理员权限执行此程序.
注意:只有当我针对更高权限的用户(SYSTEM,LOCAL SERVICE等)运行此程序时,才会发生此WriteProcessMemory和CreateRemoteThread问题.它完全适用于我拥有的程序(相同的权限).
编辑:这是整个来源的链接.http://pastebin.com/m77110d8e除了基本的错误检查之外没有其他的东西,但也许它会有帮助吗?
我有一个编辑控件(文本字段),我想要动画.我想要的动画是它滑出来,为这个文本字段创建一个额外的行.我可以为我的文本字段设置动画并使其更大,但是为了显示我首先要隐藏它的滑动动画.这意味着整个文本字段滑出,好像是第一次从零开始创建,而不是仅添加新行.
这是我现在的代码:
SetWindowPos(hwnd, HWND_TOP, x, y, newWidth, newHeight, SWP_DRAWFRAME);
ShowWindow(hwnd, SW_HIDE);
AnimateWindow(hwnd, 300, AW_SLIDE | AW_VER_NEGATIVE);
Run Code Online (Sandbox Code Playgroud)
是否可以在不隐藏它的情况下显示此动画?
我期待为即将开展的项目实施每日构建.
但在此之前,我需要知道如何正确版本的程序集.
我有以下问题:
我们正在实施sharepoint应用程序,我们想知道SharePoint工作流程与Windows工作流程的优缺点.
我有一个这样的课:
public class Product : IProduct
{
static private string _defaultName = "default";
private string _name;
private float _price;
/// Constructor
public Product()
{
_price = 10.0F;
}
public void ModifyPrice(float modifier)
{
_price = _price * modifier;
}
Run Code Online (Sandbox Code Playgroud)
我希望ModifyPrice不为特定值做任何事情,但我也想调用将价格设置为10的构造函数.我尝试过这样的事情:
var fake = new SProduct() { CallBase = true };
var mole = new MProduct(fake)
{
ModifyPriceSingle = (actual) =>
{
if (actual != 20.0f)
{
MolesContext.ExecuteWithoutMoles(() => fake.ModifyPrice(actual));
}
}
};
MProduct.Constructor = (@this) => (@this) = …Run Code Online (Sandbox Code Playgroud) 我有SAP RPC OCX控件,我想使用它.在C#4下面的代码工作正常:
System.Type t = System.Type.GetTypeFromProgID("SAP.Functions", true);
dynamic fc = System.Activator.CreateInstance(t, false);
dynamic connection = fc.Connection;
connection.System = "";
Run Code Online (Sandbox Code Playgroud)
以下代码不起作用(即使连接不为null)
System.Type t = System.Type.GetTypeFromProgID("SAP.Functions", true);
dynamic fc = System.Activator.CreateInstance(t, false);
var connection = fc.Connection as SAPLogonCtrl.Connection
connection.System = "";
Run Code Online (Sandbox Code Playgroud)
抛出以下错误:"尝试读取或写入受保护的内存.这通常表示其他内存已损坏."
最奇怪的事实是:
System.Type t = System.Type.GetTypeFromProgID("SAP.Functions", true);
dynamic fc = System.Activator.CreateInstance(t, false);
dynamic c1 = fc.Connection;
var c2 = fc.Connection as SAPLogonCtrl.Connection;
if (c1 == c2)
c2.System = "";
Run Code Online (Sandbox Code Playgroud)
最后一行被执行并抛出相同的异常!用c1替换c2按预期工作...
我觉得我错过了一些微不足道的事情,但我完全失去了...请帮帮忙?
其他信息:改变自:
dynamic fc = System.Activator.CreateInstance(t, false);
Run Code Online (Sandbox Code Playgroud)
至:
var fc …Run Code Online (Sandbox Code Playgroud) 我的代码中有一个小错误,我不能为我的生活弄清楚.
我有一个字符串数组,它们是二进制数据的表示形式(在从十六进制转换之后),例如:一个索引是1011,另一个是11100.我遍历数组并用0填充每个索引,以便每个索引是8个字节.当我尝试将这些表示转换为实际字节时,当我尝试解析'11111111'时出现错误我得到的错误是:
java.lang.NumberFormatException: Value out of range. Value:"11111111" Radix:2
Run Code Online (Sandbox Code Playgroud)
这是一个片段:
String source = a.get("image block");
int val;
byte imageData[] = new byte[source.length()/2];
try {
f.createNewFile();
FileOutputStream output = new FileOutputStream(f);
for (int i=0; i<source.length(); i+=2) {
val = Integer.parseInt(source.substring(i, i+2), 16);
String temp = Integer.toBinaryString(val);
while (temp.length() != 8) {
temp = "0" + temp;
}
imageData[i/2] = Byte.parseByte(temp, 2);
}
Run Code Online (Sandbox Code Playgroud) 相当于main(int argc, char*argv[])C.例如:./foo.lua -a -b我如何阅读-a和-b从foo.lua程序中读取?