#5685

Yutaka Emura
Keymaster

owilsky wrote:
I cannot tell my users to install 30 macros by hand and configure 20 keyboard shortcuts for them and create their own menus.
If it cannot be done automatically, I will try to find out how to change the reg value. Can you tell me how the general format is? I only need the format for the macros, I do not need the “normal” menu commands.
I guess there must be 3 parts per macro:
– path and filename of macro
– keyboard shortcut
– as you said the length of the entry.
– plus maybe a separator between different entries?

It may be difficult but I know I can do it!

Oliver

Here is the source code for writing a menu to the registry. I know you will have a lot of questions, but I hope you can figure them out. Ignore T2E and CV_ACP.


BOOL SaveMenuItem( CMenuArray& MenuArray, int nMenuKind, bool bDelete )
{
HKEY hKey = GetCommonRootKey();
if( hKey == NULL ) return FALSE;
BOOL bSuccess = FALSE;
if( bDelete ){
MyRegDeleteValue( hKey, aszMenu[nMenuKind] );
bSuccess = TRUE;
}
else {
int nLen;
DWORD dwCount = sizeof( int );
dwCount += sizeof(DWORD);
CMenuArray::iterator it = MenuArray.begin();
int nMax = 0;
while( it != MenuArray.end() ){
CV_ACP;
dwCount += (DWORD)wcslen( T2E( it->m_szName ) ) * sizeof(WCHAR);
dwCount += (DWORD)wcslen( T2E( it->m_szFile ) ) * sizeof(WCHAR);
dwCount += sizeof( int ) + sizeof( UINT ) + sizeof( int ) + sizeof( int );
nMax++;
it++;
}
char* pBuf = new char[dwCount];
if( pBuf != NULL ){
char* p = pBuf;
*((DWORD*)p) = SIGNATURE_MENU_LIST_2;
p += sizeof( DWORD );
*((int*)p) = nMax;
p += sizeof( int );
it = MenuArray.begin();
while( it != MenuArray.end() ){
*((UINT*)p) = it->m_nID;
p += sizeof(UINT);
*p = (char)it->m_nDepth;
p += sizeof(UINT);
CV_ACP;
LPWSTR szE = T2E( it->m_szName );
nLen = (int)wcslen( szE );
*((int*)p) = nLen;
p += sizeof( int );
memcpy( p, szE, nLen * sizeof(WCHAR) );
p += nLen * sizeof(WCHAR);

szE = T2E( it->m_szFile );
nLen = (int)wcslen( szE );
*((int*)p) = nLen;
p += sizeof( int );
memcpy( p, szE, nLen * sizeof(WCHAR) );
p += nLen * sizeof(WCHAR);

it++;
}
ASSERT( p == pBuf + dwCount );
bSuccess = ( p == pBuf + dwCount );
WriteProfileBinaryReg( hKey, aszMenu[nMenuKind], (LPBYTE)pBuf, dwCount );
delete [] pBuf;
}
}
MyRegCloseKey( hKey );
return bSuccess;
}

P.S. How about creating a popup menu using PopupMenu object in the macro?
http://www.emeditor.com/help/macro/popupmenu/index.htm