在我详细介绍之前,我想强调一下,使用PowerShell不是一种选择,因为脚本应该在PowerShell可能无法使用的机器上运行.
我需要检查Windows机器上安装的Internet Explorer版本,并根据它的版本对其进行操作.
到目前为止,我的批处理脚本如下所示:
@echo off
setlocal
for /f "tokens=*" %%a in ( 'reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer" /v Version' ) do ( set IEVerReg=%%a )
endlocal
Run Code Online (Sandbox Code Playgroud)
如您所见,我正在reg query为IEVarReg变量分配输出.在不同的Windows版本上,输出是不同的,例如:
Windows XP:
! REG.EXE VERSION 3.0
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
Version REG_SZ 8.0.6001.18702
Run Code Online (Sandbox Code Playgroud)
Windows 7的:
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer
Version REG_SZ 9.0.8112.16421
Run Code Online (Sandbox Code Playgroud)
理想情况下,我想从版本号中获取第一个数字并执行以下操作:
if
version == 8
then
execute this
elseif
version == 9
then
execute that
Run Code Online (Sandbox Code Playgroud)
我确定if一旦得到版本号,我就会弄清楚如何做这个部分,但这是我无法弄清楚的版本号部分.我可以在bash,perl等中轻松完成,但不知道Windows命令行.
非常感谢帮助.
PS.我看过Jerold Schulman的剧本,但它返回的版本号对我来说太过分了.
我看过Scott Meyers的"Effective C++"第三版,其中有一小部分是关于"模板编程"的.
包含有关模板"有效"使用信息的任何其他书籍/链接?
从David Abrahams和Aleksey Gurtovoy的书"C++ Template Metaprogramming"中我了解到iter_swap(见下文)会比std::swap有时慢得多.虽然这本书有一些解释,但我并没有得到它,有人可以通过更多细节解释其背后的原因.
template <typename ForwardIt1>
void iter_swap(ForwardIt1 it1, ForwardIt1 it2){
typedef typename std::iterator_traits<ForwardIt1>::value_type T;
T tmp = *it1;
*it1 = *it2;
*it2 = tmp;
}
template <typename ForwardIt1>
void swap_wrapper(ForwardIt1 it1, ForwardIt1 it2){
std::swap(*it1, *it2);
}
Run Code Online (Sandbox Code Playgroud)
通过应用它们std::list<std::vector<std::string>>::iterator,我发现第一个比第二个慢10倍,即使矢量的大小(其元素都是小字符串,长度小于10)仅为10.
我正在尝试使用c ++中的pthreads编写一个线程安全的队列.我的程序有93%的时间都在工作.另外7%的时间它会吐出垃圾,或者似乎睡着了.我想知道我的队列中是否存在一些上下文切换会破坏它的缺陷?
// thread-safe queue
// inspired by http://msmvps.com/blogs/vandooren/archive/2007/01/05/creating-a-thread-safe-producer-consumer-queue-in-c-without-using-locks.aspx
// only works with one producer and one consumer
#include <pthread.h>
#include <exception>
template<class T>
class tsqueue
{
private:
volatile int m_ReadIndex, m_WriteIndex;
volatile T *m_Data;
volatile bool m_Done;
const int m_Size;
pthread_mutex_t m_ReadMutex, m_WriteMutex;
pthread_cond_t m_ReadCond, m_WriteCond;
public:
tsqueue(const int &size);
~tsqueue();
void push(const T &elem);
T pop();
void terminate();
bool isDone() const;
};
template <class T>
tsqueue<T>::tsqueue(const int &size) : m_ReadIndex(0), m_WriteIndex(0), m_Size(size), m_Done(false) {
m_Data = new T[size]; …Run Code Online (Sandbox Code Playgroud) 我有第三方库.(msvc10)MT/MD(静态cfgs)和动态DLL cfg.
我有qt + msvc10 express + win sdk.7
好吧,我使用提供的现有示例,(使用libs)我无法编译.....我有4个未解决的同一个lib的外部错误.(但我对其他人没有错误)我不支持这些lib ......(但他们是合法的,我是没有权利的成员)
调查可能的修复的步骤是什么?在哪里我要看?谢谢.
编辑1:
错误是:
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegEnumValueW@32 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor@ExHostAppServices@@UAE_N ABVOdTtfDescriptor@@AAVOdString@@@Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor@ExHostAppServices@@UAE_N ABVOdTtfDescriptor@@AAVOdString@@@Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExW@24 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString …Run Code Online (Sandbox Code Playgroud) 我正在创建一个应用程序,它将使用鼠标/键盘(宏)模拟一个变量值的动作.
我在这里扫描了我制作的代码:
void ReadMemory(int value){
DWORD primeiroAddress = 0x000000;
DWORD finalAddress = 0xFFFFFF;
DWORD address=0;
std::ostringstream ss;
int i=0;
TListItem *ListIt;
int valor;
HANDLE phandle = OpenProcess(PROCESS_VM_READ,0,TargetPID);
if(!phandle){
ShowMessage("Não encoutrou o processo");
}else{
for(address=primeiroAddress;address<=finalAddress;address+=sizeof(valor)){
ReadProcessMemory(phandle,(void*)address,&valor,sizeof(valor),0);
if(valor==value){
i++;
ss << std::hex << address;
Form1->Label5->Caption=i;
ListIt = Form1->ListView1->Items->Add();
ListIt->Caption = AnsiString(ss.str().c_str()).UpperCase();
ListIt->SubItems->Add(IntToStr(valor));
ss.str(std::string());
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道我能做些什么才能让扫描速度更快
我正在阅读一些代码并遇到了这个问题.我现在没有整个上下文保存这一行.
cout<<(*--*++ptr+1)<< endl;
Run Code Online (Sandbox Code Playgroud)
这个编译很好,当我们在其中输入值时工作.
它的声明是这样的.
char ***ptr ;
Run Code Online (Sandbox Code Playgroud)
这个运营商是什么,它是否包含在标准中?
该项目在VC6.0下正常运行,但是,在VS2012下更新后,出现以下链接错误:
revel.lib(BaseEncoder.obj) : error LNK2019: unresolved external symbol
"__declspec(dllimport) private: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Eos(unsigned int)"
(__imp_?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z) referenced in function
"protected: virtual void __thiscall Revel_BaseEncoder::Reset(void)" (?Reset@Revel_BaseEncoder@@MAEXXZ)
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题吗?非常感谢!
我正在尝试使用测试库的静态版本来源构建.我有libtest.a和libtest.so可用,所以我使用"-static"选项.但是,看起来gcc链接器也试图搜索标准数学库的静态版本.知道我可以使用什么选项来链接标准库的共享版本吗?
g++ -static main.cpp -o a.out -L. -ltest
Run Code Online (Sandbox Code Playgroud)
错误:
/usr/bin/ld: cannot find -lm
Run Code Online (Sandbox Code Playgroud)
我有以下代码会对我产生意外的结果:
#include < stdio.h >
int a = 0, value;
int main(void)
{
// Testing the evaluation order of multiple
// conditional operators:
value = (a == 3) ? 3 : (a = 3) ? 5 : 0;
printf("%d\n", value);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我希望此代码能打印3,因为条件运算符的计算
从右到左,并且在?处有一个序列点。先执行
操作的结果,而实际上会打印出5。
假定表达式
的值是时,假设还计算了两个序列点之间的表达式的副作用,是否错误?
如果我添加printf(“%d \ n” a); 我虽然打印了3张,但副作用得到了解决。
还是只是控制剂量确实传递给了子表达式,其值
被正式“首次”计算?
我宁愿押注后者,因为将'a'的值更改为3并将右值
将第二个条件条件赋值为4导致
对第一个条件表达式进行短路评估,这意味着我同时为“ a”和“ value”打印了3个值。
我使用-std = c99标志在带有GCC 4.8.2的Lubuntu 14.04上获得了上述结果。
感谢您让我澄清此事!
我陷入了这段代码......我想从用户那里获取输入并将其移动到寄存器中......但是寄存器是16位的并且输入存储在Al中,这是8位的......有没有办法将值从 AL 移动到像 BX 这样的寄存器...我这样做是因为我想在数组中使用 BX,例如 array[bx]....请帮我解决这个问题..
.MODEL SMALL
.STACK 100H
.DATA
MSG DB 10,13,"TIC TAC TOE $"
MSG1 DB " $"
ARR1 DB '1','2','3','4','5','6','7','8','9'
MSG2 DB 10,13,"PLAYER 1 WIN $"
MSG3 DB 10,13,"PLAYER 2 WIN $"
MSG4 DB 10,13,"GAME DRAW $"
VAR DW ?
PLAYER1 EQU 'X'
PLAYER2 EQU 'O'
.CODE
MAIN PROC
MOV AX , @DATA
MOV DS , AX
NEXT_LINE1:
MOV BX , 0 ;counter
NEXT_LINE: ;this loop will shape the array in matrix form
MOV AH …Run Code Online (Sandbox Code Playgroud)