2019. 2. 16. 09:54

How to make a volatile registry using NSIS script

There is no native way to make a volatile registry key in NSIS, so we have to call WINAPI directly.

 !define REG_OPTION_VOLATILE             1

Function MakeVolatileKey

    System::Call 'advapi32::RegCreateKeyEx(i ${HKEY_LOCAL_MACHINE}, t "Software\volatile", i0, i0, i ${REG_OPTION_VOLATILE}, i ${GENERIC_WRITE}, i0, *i.r1, *i)i.r0'
    ${If} $0 = 0
            System::Call 'advapi32::RegCloseKey(ir1)'
            WriteRegDWORD HKLM "Software\volatile" test 1
    ${EndIf}
 
FunctionEnd

But, there is one thing we have to consider on 64bit Windows.
If we add a code 'SetRegView 64' in order to avoid registry redirection, two registry keys are made:
    1. HKEY_LOCAL_MACHINE\SOFTWARE\Volatile (by WriteRegDWORD)
    2, HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\volatile (by RegCreateKeyEx)
 
SetRegView can not affect native registry APIs; then we should apply a KEY_WOW64_64KEY option to RegCreateKeyEx API.


!include WinCore.nsh
!include LogicLib.nsh
!include x64.nsh

!define REG_OPTION_VOLATILE             1
!define KEY_WOW64_64KEY                 0x0100


Function MakeVolatileKey

    ${If} ${RunningX64}
        IntOp $R0 ${GENERIC_WRITE} + ${KEY_WOW64_64KEY}
        SetRegView 64
    ${Else}
        Strcpy $R0 ${GENERIC_WRITE}       
        SetRegView 32
    ${EndIf}
 
    System::Call 'advapi32::RegCreateKeyEx(i ${HKEY_LOCAL_MACHINE}, t "Software\volatile", i0, i0, i ${REG_OPTION_VOLATILE}, i $R0, i0, *i.r1, *i)i.r0'
    ${If} $0 = 0
            System::Call 'advapi32::RegCloseKey(ir1)'
            WriteRegDWORD HKLM "Software\Volatile" test 1
    ${EndIf}
 
FunctionEnd


2014. 7. 14. 09:10

C++ Cocurrency tutorial

c++ Concurrency tutorial

http://baptiste-wicht.com/categories/c11-concurrency-tutorial.html

2009. 9. 1. 11:17

XML

. Processing Instruction
  • <? .... ?> 의 형태를 가지는 노드이다.
  • 생성
    • MSXML : createProcessingInstruction( target,  data , &pi );
      • target: nodeName property 형태로 접근
      • data: nodeValue property 형태로 접근
  • 접근
    • xpath : processing-instruction('target')


2009. 6. 26. 15:36

shared_ptr tip

1. prohibit delete raw pointer( use protected destructor )

class A
{
public:
virtual void sing() = 0;
protected:
virtual ~A() {}
};

class B : public A
{
public:
virtual void sing()
{
std::cout <<"Do re mi fa so la";
}

};

boost::shared_ptr<A> createA()
{
boost::shared_ptr<A> p ( new B() );
return p;
}

int main()
{
boost::shared_ptr<A> test = createA()
delete test.get();  // compile error  because ~A is protected
}

2. prohibit delete raw pointer( nest class)

class A
{
class deleter
{
public:
void operator() (A * p )
{
delete P;
}
};

friend class deleter;

public:
virtual void sing()
{
std::cout << "Lalalalalalalala";
}

static boost::shared_ptr<A> createA()
{
boost::shared_ptr<A> p(new A(), A::deleter() );
return p;
}

protected:
virtual ~A() {}
};
2008. 11. 5. 17:25

Install QT on ubuntu linux

1. sudo apt-get update && sudo apt-get install kdevelop

2. sudo apt-get install automake

3. sudo apt-get install libqt4-core libqt4-dev libqt4-gui 
qt4-dev-tools qt4-designer