Beispiel #1
0
Datei: 71.c Projekt: FTCr/Siemens
void Create71Editor(void)
{
	if (InitLGP())
	{
		char ver;
		unsigned int size;
		if (GetEELiteBlockSizeVersion(71, &size, &ver) == 0)
		{
			_71 *_71 = malloc(sizeof(_71));
			_71->data = malloc(size);
			_71->size = size;
			_71->ver = ver;
			
			if (EELiteReadBlock(71, _71->data, 0, size + 1) != -1)
			{
				_71->offset = _71->data[0] * 3 + 1;
				int items = _71->data[_71->offset];
				_71->offset += 3;
				
				sk[0].lgp_id  = (int)lgp[lgpWrite];
				sk[1].lgp_id  = (int)lgp[lgpBack];
				header.lgp_id = (int)lgp[lgpEdit71];
				patch_header(&header);
				CreateMenu(0, 0, &desc, &header, 0, items, _71, NULL);
			}
		}
	}
	else
		MsgBoxError(1, (int)"Error");
}
Beispiel #2
0
extern 	double EXPORT PASCAL s2wrapper ( char *what, double val, int index)
{
	fprintf(logfile,"%s\tfunction:cellp.s2wrapper\twhat:%s\tval:%12f\tindex:%d\n", gettime(),what,val,index);
  	if (strcmp(what,"PeekCN") == 0)  
	{
 		return(getcellcounts(index,!VEGF));
	}
	if (strcmp(what,"PokePgfCN") == 0)  
	{
	
    		cellstart[index]=val;
		    /* index is the celltype, cellstart is for jointpgf() */
    		return(DZERO);
    }
    if (strcmp(what,"InitTox") == 0) 
    {
    	nToxTypes = 0;
    	InitToxTypes();
    	return(DZERO);
    }
#ifdef DLL    
    	MsgBoxError("Invalid Call to s2wrapper");
#endif
    	return ((double) -1); /*error*/
}
Beispiel #3
0
// *** IContextMenu methods ***
STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) {
	UINT idCmd = idCmdFirst;

	FORMATETC fmte = {
		CF_HDROP,
		(DVTARGETDEVICE FAR *)NULL,
		DVASPECT_CONTENT,
		-1,
		TYMED_HGLOBAL
	};

	HRESULT hres = m_pDataObj->GetData(&fmte, &m_stgMedium);

	if (SUCCEEDED(hres)) {
		if (m_stgMedium.hGlobal)
			m_cbFiles = DragQueryFile((HDROP)m_stgMedium.hGlobal, (UINT)-1, 0, 0);
	}

	UINT nIndex = indexMenu++;

	InsertMenu(hMenu, nIndex, MF_STRING|MF_BYPOSITION, idCmd++, m_szMenuTitle);

	HBITMAP icon = NULL;
	if (m_showIcon) {/*
		if (m_supportARGB32) {
			icon = NULL;
			HICON hicon;
			DWORD menuIconWidth = GetSystemMetrics(SM_CXMENUCHECK);
			DWORD menuIconHeight = GetSystemMetrics(SM_CYMENUCHECK);
			HRESULT hr = LoadShellIcon(menuIconWidth, menuIconHeight, &hicon);
			if (SUCCEEDED(hr)) {
				HBITMAP hbitmap;
				LoadARGBBitmap(hicon, menuIconWidth, menuIconHeight, &hbitmap);
				if (SUCCEEDED(hr)) {
					icon = hbitmap;
				}
			}
		} else {
			icon = HBMMENU_CALLBACK;
		}*/
		DWORD menuIconWidth = GetSystemMetrics(SM_CXMENUCHECK);
		DWORD menuIconHeight = GetSystemMetrics(SM_CYMENUCHECK);
		HRESULT hr = LoadShellBitmap(menuIconWidth, menuIconHeight, &icon);
		if (FAILED(hr))
			MsgBoxError(TEXT("Help"));
	}

	MENUITEMINFO mii;
	ZeroMemory(&mii, sizeof(mii));
	mii.cbSize = sizeof(mii);
	mii.fMask = MIIM_BITMAP;
	mii.hbmpItem = icon;
	//SetMenuItemInfo(hMenu, nIndex, MF_BYPOSITION, &mii);
	SetMenuItemBitmaps(hMenu, nIndex, MF_BYPOSITION, icon, icon);

	m_hMenu = hMenu;
	m_menuID = idCmd;

	return ResultFromShort(idCmd-idCmdFirst);
}
void ZShadeMessageCenter::ErrorExit(LPTSTR lpszFunction) 
{ 
    // Retrieve the system error message for the last-error code

    LPVOID lpMsgBuf;
    LPVOID lpDisplayBuf;
    DWORD dw = GetLastError(); 

    FormatMessage(
        FORMAT_MESSAGE_ALLOCATE_BUFFER | 
        FORMAT_MESSAGE_FROM_SYSTEM |
        FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL,
        dw,
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR) &lpMsgBuf,
        0, NULL );

    // Display the error message and exit the process
	
    lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, 
        (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR));
    StringCchPrintf((LPTSTR)lpDisplayBuf, 
        LocalSize(lpDisplayBuf) / sizeof(TCHAR),
        TEXT("%s failed with error %d: %s"), 
        lpszFunction, dw, lpMsgBuf);
	MsgBoxError(NULL, (LPCTSTR)lpDisplayBuf, "ZShade ERROR", MB_ICONFLAGS.IconError);

    LocalFree(lpMsgBuf);
    LocalFree(lpDisplayBuf);
    ExitProcess(dw);
}
void ZShadeMessageCenter::Assert(bool condition, LPCSTR text)
{
	if (!condition)
	{
		MsgBoxError(NULL, text);
		
		PostQuitMessage(0);
	}
}
void TrackInfo(void)
{
    unsigned int i = GetCurMenuItem(tab_tracks_gui);
    DIR_ENTRY_LIST *ptr = APlayer_GetPtr(i);
    if (ptr->data)
        CreateTagsGUI(ptr->data);
    else
        MsgBoxError(1, (int)"Empty tag!");
}
Beispiel #7
0
//---------------------------------------------------------------------------
// RegisterServer
//---------------------------------------------------------------------------
BOOL RegisterServer(CLSID clsid, LPTSTR lpszTitle) {
  int      i;
  HKEY     hKey;
  LRESULT  lResult;
  DWORD    dwDisp;
  TCHAR    szSubKey[MAX_PATH];
  TCHAR    szCLSID[MAX_PATH];
  TCHAR    szModule[MAX_PATH];
  LPWSTR   pwsz;

  if (!CheckNpp()) {
    MsgBoxError(TEXT("To register the Notepad++ context menu extension,\r\ninstall nppcm.dll in the same directory than Notepad++.exe."));
    return FALSE;
  }

  StringFromIID(clsid, &pwsz);
  if(pwsz) {
#ifdef UNICODE
    lstrcpy(szCLSID, pwsz);
#else
    WideCharToMultiByte(CP_ACP, 0, pwsz, -1, szCLSID, ARRAYSIZE(szCLSID), NULL, NULL);
#endif
    //free the string
    LPMALLOC pMalloc;
    CoGetMalloc(1, &pMalloc);
    pMalloc->Free(pwsz);
    pMalloc->Release();
  }

  //get this app's path and file name
  GetModuleFileName(_hModule, szModule, MAX_PATH);

  DOREGSTRUCT ClsidEntries[] = {
    HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s"),                              NULL,                   lpszTitle,
    HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocServer32"),              NULL,                   szModule,
    HKEY_CLASSES_ROOT,   TEXT("CLSID\\%s\\InprocServer32"),              TEXT("ThreadingModel"), TEXT("Apartment"),
    HKEY_CLASSES_ROOT,   TEXT("*\\shellex\\ContextMenuHandlers\\Notepad++"), NULL,                   szCLSID,
    NULL,                NULL,                                           NULL,                   NULL
  };

  // Register the CLSID entries
  for(i = 0; ClsidEntries[i].hRootKey; i++) {
    // Create the sub key string - for this case, insert the file extension
    wsprintf(szSubKey, ClsidEntries[i].szSubKey, szCLSID);
    lResult = RegCreateKeyEx(ClsidEntries[i].hRootKey, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp);
    if(NOERROR == lResult) {
      TCHAR szData[MAX_PATH];
      // If necessary, create the value string
      wsprintf(szData, ClsidEntries[i].szData, szModule);
      lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, REG_SZ, (LPBYTE)szData, (lstrlen(szData) + 1) * sizeof(TCHAR));
      RegCloseKey(hKey);
    }
    else
      return FALSE;
  }
  return TRUE;
}
int GroupMgr()
{
	/* User mgr Key */
	
	if(gethostname(computer, 255) !=0 || uname(&uts) < 0)
	{
		MsgBoxError("Unable to get hostname information");
	}
	
	
	int GroupMgrItem = 0;
	keypad(stdscr, TRUE);
	noecho();
	
	while(1)
	{
		DrawGroupMgrScreen(GroupMgrItem);
		
		do
		{
			GRkey = getch();
			switch(GRkey)
			{
				case KEY_F(2):
					listgrctr = 100;
					newgrlist = 0;
					break;
				case KEY_F(3):
					useradd();
					break;
				case KEY_F(10):
					return 0;
				break;;
				
				case KEY_DOWN:
					wscrl(GroupPad, 3);
					//mvprintw(1, x/2, "Username: %s", usernames[UserNo++]);
					
				break;;
				
				case KEY_UP:
					wscrl(GroupPad, -3);
				break;;
				
				
			};
			DrawGroupMgrScreen(GroupMgrItem);
		} while(GRkey != '\n');
		
		/* Responses */
	
	}; /*End of While */
	
	return 0;
}
Beispiel #9
0
STDAPI DllInstall(BOOL bInstall, LPCWSTR /*pszCmdLine*/) {
	if (bInstall) {
		DialogBox(_hModule, MAKEINTRESOURCE(IDD_DIALOG_SETTINGS), NULL, (DLGPROC)&DlgProcSettings);
		return S_OK;
	} else {
		MsgBoxError(TEXT("Uninstalling not supported, use DllUnregisterServer instead"));
		return E_NOTIMPL;
	}

	return S_OK;
}
Beispiel #10
0
int DrawFSDefaultScreen(char *title)
{
	char SCROLLOPT[] = "Up: Scroll Up		Down: Scroll Down";
	char FSUIOPTS1[] = "F1=Help		F2=Refresh		F10=Quit";
	
	/* Clears Screen, Gets vales of X, Y, Enable Keypad
	 * disable echo, draws a box on stdscr, adds a title to screen */
	 
	clear();
	getmaxyx(stdscr, y,x);
	keypad(stdscr, TRUE);
	noecho();
	box(stdscr, ACS_VLINE, ACS_HLINE);
	mvaddstr(1, x/6, title);
	mvaddstr(y-4, 2, SCROLLOPT);
	mvaddstr(y-2, 2, FSUIOPTS1);
	
	
	/* Make Windows, SPARE Window is Windows that has a border
	 * to prevent overwriting on the borders*/
	 
	SPARE = newwin(15, 76, 4, 2);
	box(SPARE, ACS_VLINE, ACS_HLINE);
	
	/*  Creates a PAD (Window that is larger than screen sizes better 
	 *  for scrolling */
	 
	 if(PADCREATED <1) {
		 /* Pad 30 lines x 68 column */
		 FSPAD = newpad(30, 74);
			if(FSPAD == NULL) {
				MsgBoxError("Unable to create Filesystem PAD");
				return(1);
			 };
			 scrollok(FSPAD, TRUE);
			 PADCREATED = 1;
		 }
	 /* else
			{
				prefresh(FSPAD, 15, 1, 4, 3, 14, 39);
			} */
	
	
	refresh();
	wrefresh(SPARE);
	prefresh(FSPAD, 15, 1, 5, 3, 14, 74);
	
	return 0;
}
void AddLanguageDialog::onAddLanguage()
{
    if (ui->listWidgetLanguage->selectedItems().count() == 0)
    {
        MsgBoxInformation(tr("Please select language to add first."));
        return;
    }

    QListWidgetItem *item = ui->listWidgetLanguage->selectedItems()[0];

    QString sourcePath = QFileDialog::getOpenFileName(this, tr("Open Language File"), g_AppDirPath, tr("Language Files (*.lang)"));
    QString destinationPath = g_LanguagesPath + "/" + item->data(Qt::UserRole).toString() + ".lang";

    if (!sourcePath.isEmpty())
    {
        if (QFile::exists(destinationPath))
        {
            if (!QFile::remove(destinationPath))
            {
                MsgBoxError(tr("Same language file already exists in the languages folder. It could not be removed. Perhaps you should try running application with administrative privileges."));
                return;
            }
        }
        if (!QFile::copy(sourcePath, destinationPath))
        {
            MsgBoxError(tr("Could not copy language file into languages folder. Perhaps you should try running application with administrative privileges."));
            return;
        }
        MsgBoxInformation(tr("Language file was added successfully."));
        accept();
    }
    else
    {
        return;
    }
}
Beispiel #12
0
STDMETHODIMP CShellExt::InvokeNpp(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd) {
  TCHAR szFileUserClickedOn[MAX_PATH];
  LPTSTR pszCommand;
  UINT i;

  FORMATETC fmte = {
    CF_HDROP,
    (DVTARGETDEVICE FAR *)NULL,
    DVASPECT_CONTENT,
    -1,
    TYMED_HGLOBAL
  };

  pszCommand = (LPTSTR)m_pAlloc->Alloc(MAX_PATH * (m_cbFiles + 1) * sizeof(TCHAR));

  if (pszCommand)
    getNppName(pszCommand);
  else {
    MsgBoxError(TEXT("Insufficient memory available."));
    return E_FAIL;
  }

  for (i = 0; i < m_cbFiles; i++) {
    DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFileUserClickedOn, MAX_PATH);
    lstrcat(pszCommand, TEXT(" \""));
    lstrcat(pszCommand, szFileUserClickedOn);
    lstrcat(pszCommand, TEXT("\""));
  }

  STARTUPINFO si;
  PROCESS_INFORMATION pi;
  ZeroMemory(&si, sizeof(si));
  si.cb = sizeof(si);
  si.dwFlags = STARTF_USESHOWWINDOW;
  si.wShowWindow = SW_RESTORE;
  if (!CreateProcess (NULL, pszCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
    MessageBox(hParent,
               TEXT("Error creating process: nppcm.dll needs to be in the same directory than notepad++.exe"),
               TEXT("Notepad++ Extension"),
               MB_OK);
  }

  m_pAlloc->Free(pszCommand);
  return NOERROR;
}
void Delete(int flag)
{
    if (!flag)
    {
        unsigned int i = GetCurMenuItem(tab_tracks_gui);
        if (APlayer_GetTrack() - 1 == i)
        {
            MsgBoxError(1, (int)"Error!");
        }
        else
        {
            DIR_ENTRY_LIST *ptr = APlayer_GetPtr(i);
            unsigned int err;
            _unlink(ptr->path, &err);
            APlayer_CutFile(i);
            Menu_SetItemCountDyn(tab_tracks_gui, APlayer_GetTotalTracks());
        }
    }
}
Beispiel #14
0
int main(const char *exe_path, const char *file_path)
{
	if (InitLang(cfg_lang_path, &lgp) == -1)
	{
		MsgBoxError(1, (int)"lang.txt not found!");
		kill_elf();
	}
	else
	{
		CSM_RAM *save_cmpc;
		char dummy[sizeof(MAIN_CSM)];
		LockSched();
		UpdateCSMname();
		InitConfig();
		save_cmpc = CSM_root()->csm_q->current_msg_processing_csm;
		CSM_root()->csm_q->current_msg_processing_csm = CSM_root()->csm_q->csm.first;
		CreateCSM(&MAINCSM.maincsm,dummy,0);
		CSM_root()->csm_q->current_msg_processing_csm = save_cmpc;
		UnlockSched();
		AddKeybMsgHook((void*)KeyHook);
	}
	return 0;
}
Beispiel #15
0
extern 	double EXPORT PASCAL s2wrapper ( char *what, double val, int index)
{
    if (strcmp(what,"PeekCN") == 0)
    {
        return(getcellcounts(index,!VEGF));
    }
    if (strcmp(what,"PokePgfCN") == 0)
    {

        cellstart[index]=val;
        /* index is the celltype, cellstart is for jointpgf() */
        return(DZERO);
    }
    if (strcmp(what,"InitTox") == 0)
    {
        nToxTypes = 0;
        InitToxTypes();
        return(DZERO);
    }
#ifdef DLL
    MsgBoxError("Invalid Call to s2wrapper");
#endif
    return ((double) -1); /*error*/
}
Beispiel #16
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(false);
    app.setApplicationName(APP_NAME);
    app.setApplicationVersion("2.0");
    app.setOrganizationName(ORGANIZATION_NAME);

    bool bCallRequest = false;

    g_LanguagesPath         = QApplication::applicationDirPath() + "/lang";
    g_AppSettingsFolderPath = QDir::homePath() + "/OutCALL";
    g_AppDirPath            = QApplication::applicationDirPath();

    if (argc==2 && QString(argv[1]) == "installer")
    {
        // Setup log file paths
        QDir().mkpath(g_AppSettingsFolderPath);
        QFile(g_AppSettingsFolderPath + "/outcall.log").remove();

        if (global::IsOutlookInstalled())
        {
            if (global::EnableOutlookIntegration(true))
                global::log("Outlook plugin installed successfully.", LOG_INFORMATION);
            else
                global::log("Could not install Outlook plugin.", LOG_ERROR);
        }
        else
        {
            global::log("Outlook was not detected.", LOG_INFORMATION);
        }
        return 0;
    }

    if (argc == 2)
    {
        bCallRequest = QString(argv[1]).contains("Dial#####");
    }

    if (bCallRequest)
    {
        QStringList arguments = QString(argv[1]).split("#####");
        QString contactName = arguments[1];
        QString numbers = QString(arguments[2]).replace("outcall://", "");

        contactName.replace("&&&", " ");
        numbers.replace("&&&", " ");

        QLocalSocket s;
        s.connectToServer(LOCAL_SERVER_NAME);

        global::log("MAIN LOCAL", LOG_INFORMATION);

        QString msg = QObject::tr("It appears that %1 is not running.\n" \
                                  "Note for Windows 7/Vista users: please make sure that %2 and Outlook are running under same level of privileges. " \
                                  "Either both elevated (Run as Administrator option) or non-elevated.").arg(APP_NAME).arg(APP_NAME);

        if (!s.waitForConnected(2000))
        {
            MsgBoxInformation(msg);
        }
        else
        {
            if (!s.waitForReadyRead(2000)) // wait for "OK" from the local server
            {
                MsgBoxInformation(QObject::tr("Timeout on local socket. Maybe %1 is not running?").arg(APP_NAME));
            }
            else
            {
                QByteArray socket_data = QString("outlook_call %1 %2\n").arg(QString(contactName.toLatin1().toBase64())).
                                         arg(QString(numbers.toLatin1().toBase64())).toLatin1();
                s.write(socket_data);

                if (!s.waitForBytesWritten(2000))
                    MsgBoxError(QObject::tr("Failed local socket write()."));
            }
        }
        s.disconnectFromServer();
        s.close();

        return 0;
    }

    Notifier notifier;
    QString lang = global::getSettingsValue("language", "general").toString();
    QTranslator translator;
    if (!lang.isEmpty())
    {
        if (translator.load(QString("%1/%2.lang").arg(g_LanguagesPath).arg(lang)))
        {
            qApp->installTranslator(&translator);
        }
        else
        {
            global::setSettingsValue("language", "", "general");
            MsgBoxError(QObject::tr("Failed to load language file."));
        }
    }

    QString username  = global::getSettingsValue("username", "settings").toString();
    QByteArray secret = global::getSettingsValue("password", "settings").toByteArray();
    AsteriskManager manager(username, QString(QByteArray::fromBase64(secret)));

    OutCall outcall;
    outcall.show();

    LocalServer localServer;
    return app.exec();
}
Beispiel #17
0
int WINAPI DllMain( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
{

	FILE *inputfile;
    char strTemp[5];
	char strTcap[9];
    DWORD varsize;

	void TrialSetup();
	switch (fdwReason)
	{
	/* No multiple thread support  */
	case DLL_THREAD_ATTACH :
	case DLL_THREAD_DETACH :
		break;

	/* When process begins open logfile, initialize most stuff by calling
	 infile with a default parameter file, set conditions  */
	case DLL_PROCESS_ATTACH :
		strcpy(strTemp,"TEMP");
		strcpy(strTcap,"TCAPHOME");
		
		if ((varsize = GetEnvironmentVariable(strTemp, WorkingDir, 255)) == 0)
			MsgBoxError("TEMP environment variable not set");
	
/*		if ((varsize = GetEnvironmentVariable(strTcap, ArchiveDir, 247)) == 0)
            MsgBoxError("TCAPHOME environment variable not set");
*/
/*		SetVersion(); */
		SetHomeDir();
		
		strcat(ArchiveDir, "\\archive");

		INFINITESIMAL = 1e-12;
		INFINITY = 1e12;

		//TrialSetup();
		strcpy (ofilname, WorkingDir);
		strcat (ofilname, "\\pgf.dat");
		if (( eout = fopen(ofilname,"w")) ==  NULL)
		{
			MessageBox(NULL,"ERROR: pgf.dat failed open","treat.dll",MB_ICONEXCLAMATION | MB_OK);
			return (FALSE);
		}
       
		strcpy (infilname, ArchiveDir);
		strcat (infilname, "\\default.par");

		if (( inputfile = fopen(infilname,"r")) == NULL )
		{
			fprintf(eout,"Error opening default.par\n");
			MsgBoxWarning("Can't open default.par");
			fclose ( eout );
			return (FALSE);
		}
		else
		{

			fprintf(eout,"Reading default parameters (PAR.PANEL)\n");

			infile ( inputfile );
			fclose ( inputfile );
		}
			
		nconds = 0;
		nenvlist = 0;
		nICrules = 0;
		incondition ( /* inputfile */ );

		//create event objects to use in syncronizing event and cell
		//queue operations

		SimRunning = False;
		EndSim = False;
		MEndSim = False;
		break;
	
	/*  When process terminates close the logfile.*/
	case DLL_PROCESS_DETACH :
		fclose( eout );
		break;
	}

	return TRUE;
}
int DrawGroupMgrScreen(int grpitem)
{
	/* Bottom Bar that shows Options */
	char GR_FKEYS1[] = "F1=Help		F2=Refresh		F3=Add Group";
	char GR_FKEYS2[] = "F4=Modify Group	F5=Remove Group		F9=Shell";
	char GR_FKEYS3[] = "F10=Exit		Enter=Do/Select";
	
	/* Attempt to Select usernames */
	//int UserCounter = 0;
	
	int begy = 5, begx = 3 ;
	

	
	clear();
	getmaxyx(stdscr, y, x);
	box(stdscr, ACS_VLINE, ACS_HLINE);
	
	
	attron(A_BOLD);
	
	mvprintw(4,	5, "Group Name");
	mvprintw(4, 25, "Group ID");
	/*mvprintw(4, 25, "GID");
	mvprintw(4, 38, "Comment"); */
	mvaddstr(y-4, 2, GR_FKEYS1);
	mvaddstr(y-3, 2, GR_FKEYS2);
	mvaddstr(y-2, 2, GR_FKEYS3);
	attroff(A_BOLD);
	
	SPARE = newwin(y-10, x-2, begy, 1);
	box(SPARE, '|', '-'); 
	
	
	
	
	refresh();
	wrefresh(SPARE);
	
	
	if(GPADCreated < 1)
	{
		GroupPad = newpad(500, x-5);
		if (GroupPad == NULL)
			{
			MsgBoxError("Unable to create pad");
			return (1);
			};
		scrollok(GroupPad, TRUE);
		GPADCreated = 1;
	}
	else
	{
	  prefresh(GroupPad, 100, 	 0,    begy+1,  begx,	  y-7, 	   x-5);
		
	}
	
		
	
	
	
	refresh();

	 /* List users in to box */
	listgroups();
	attron(A_BOLD);
	mvprintw(2, 2, "Total Groups on %s: %d", computer, MaxGroups);
	attroff(A_BOLD);
	
	refresh();
	
	/*				  Origin  			Destination & Size 
	 * 	Padname,  PMinRow, PMinCol, sminrow,  smincol, 	 smaxrow,  smaxcol  */ 
	
	//prefresh(UserPad, 100,  1, 		   3,  2,	        110, 80);
	prefresh(GroupPad, 100, 	 0,    begy+1,  begx,	  y-7, 	   x-5);
	
	return 0;
}
Beispiel #19
0
// *** Private methods ***
STDMETHODIMP CShellExt::InvokeNPP(HWND /*hParent*/, LPCSTR /*pszWorkingDir*/, LPCSTR /*pszCmd*/, LPCSTR /*pszParam*/, int iShowCmd) {
	TCHAR szFilename[MAX_PATH];
	TCHAR szCustom[MAX_PATH];
	LPTSTR pszCommand;
	size_t bytesRequired = 1;

	TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE];
	DWORD regSize = 0;
	DWORD pathSize = MAX_PATH;
	HKEY settingKey;
	LONG result;

	wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID);
	result = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, KEY_READ, &settingKey);
	if (result != ERROR_SUCCESS) {
		MsgBoxError(TEXT("Unable to open registry key."));
		return E_FAIL;
	}

	result = RegQueryValueEx(settingKey, TEXT("Path"), NULL, NULL, NULL, &regSize);
	if (result == ERROR_SUCCESS) {
		bytesRequired += regSize+2;
	} else {
		MsgBoxError(TEXT("Cannot read path to executable."));
		RegCloseKey(settingKey);
		return E_FAIL;
	}

	result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, NULL, &regSize);
	if (result == ERROR_SUCCESS) {
		bytesRequired += regSize;
	}

	for (UINT i = 0; i < m_cbFiles; i++) {
		bytesRequired += DragQueryFile((HDROP)m_stgMedium.hGlobal, i, NULL, 0);
		bytesRequired += 3;
	}

	bytesRequired *= sizeof(TCHAR);
	pszCommand = (LPTSTR)CoTaskMemAlloc(bytesRequired);
	if (!pszCommand) {
		MsgBoxError(TEXT("Insufficient memory available."));
		RegCloseKey(settingKey);
		return E_FAIL;
	}
	*pszCommand = 0;

	regSize = (DWORD)MAX_PATH*sizeof(TCHAR);
	result = RegQueryValueEx(settingKey, TEXT("Path"), NULL, NULL, (LPBYTE)(szFilename), &regSize);
	szFilename[MAX_PATH-1] = 0;
	lstrcat(pszCommand, TEXT("\""));
	lstrcat(pszCommand, szFilename);
	lstrcat(pszCommand, TEXT("\""));
	result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, (LPBYTE)(szCustom), &pathSize);
	if (result == ERROR_SUCCESS) {
		lstrcat(pszCommand, TEXT(" "));
		lstrcat(pszCommand, szCustom);
	}
	RegCloseKey(settingKey);

	for (UINT i = 0; i < m_cbFiles; i++) {
		DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFilename, MAX_PATH);
		lstrcat(pszCommand, TEXT(" \""));
		lstrcat(pszCommand, szFilename);
		lstrcat(pszCommand, TEXT("\""));
	}

	STARTUPINFO si;
	PROCESS_INFORMATION pi;
	ZeroMemory(&si, sizeof(si));
	si.cb = sizeof(si);
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = iShowCmd;	//SW_RESTORE;
	if (!CreateProcess (NULL, pszCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
		DWORD errorCode = GetLastError();
		if (errorCode == ERROR_ELEVATION_REQUIRED) {	//Fallback to shellexecute
			CoInitializeEx(NULL, 0);
			HINSTANCE execVal = ShellExecute(NULL, TEXT("runas"), pszCommand, NULL, NULL, iShowCmd);
			CoUninitialize();
			if (execVal <= (HINSTANCE)32) {
				TCHAR * message = new TCHAR[512+bytesRequired];
				wsprintf(message, TEXT("ShellExecute failed (%d): Is this command correct?\r\n%s"), execVal, pszCommand);
				MsgBoxError(message);
				delete [] message;
			}
		} else {
			TCHAR * message = new TCHAR[512+bytesRequired];
			wsprintf(message, TEXT("Error in CreateProcess (%d): Is this command correct?\r\n%s"), errorCode, pszCommand);
			MsgBoxError(message);
			delete [] message;
		}
	}



	CoTaskMemFree(pszCommand);
	return NOERROR;
}
Beispiel #20
0
//---------------------------------------------------------------------------
// RegisterServer
// Create registry entries and setup the shell extension
//---------------------------------------------------------------------------
BOOL RegisterServer() {
	int      i;
	HKEY     hKey;
	LRESULT  lResult;
	DWORD    dwDisp;
	TCHAR    szSubKey[MAX_PATH];
	TCHAR    szModule[MAX_PATH];
	TCHAR    szDefaultPath[MAX_PATH];

	GetModuleFileName(_hModule, szDefaultPath, MAX_PATH);
	TCHAR* pDest = StrRChr(szDefaultPath, NULL, TEXT('\\'));
	pDest++;
	pDest[0] = 0;
	lstrcat(szDefaultPath, szNppName);

	if (!CheckNpp(szDefaultPath)) {
		MsgBoxError(TEXT("To register the Notepad++ shell extension properly,\r\nplace NppShell.dll in the same directory as the Notepad++ executable."));
		//return FALSE;
	}

	//get this app's path and file name
	GetModuleFileName(_hModule, szModule, MAX_PATH);

	static DOREGSTRUCT ClsidEntries[] = {
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s"),									NULL,					REG_SZ,		szShellExtensionTitle},
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s\\InprocServer32"),					NULL,					REG_SZ,		szModule},
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s\\InprocServer32"),					TEXT("ThreadingModel"),	REG_SZ,		TEXT("Apartment")},

		//Settings
		// Context menu
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s\\Settings"),						TEXT("Title"),			REG_SZ,		szDefaultMenutext},
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s\\Settings"),						TEXT("Path"),			REG_SZ,		szDefaultPath},
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s\\Settings"),						TEXT("Custom"),			REG_SZ,		szDefaultCustomcommand},
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s\\Settings"),						TEXT("ShowIcon"),		REG_DWORD,	(LPTSTR)&showIcon},
		// Icon
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s\\Settings"),						TEXT("Dynamic"),		REG_DWORD,	(LPTSTR)&isDynamic},
		{HKEY_CLASSES_ROOT,	TEXT("CLSID\\%s\\Settings"),						TEXT("Maxtext"),		REG_DWORD,	(LPTSTR)&maxText},

		//Registration
		// Context menu
		{HKEY_CLASSES_ROOT,	szShellExtensionKey,	NULL,					REG_SZ,		szGUID},
		// Icon
		//{HKEY_CLASSES_ROOT,	TEXT("Notepad++_file\\shellex\\IconHandler"),		NULL,					REG_SZ,		szGUID},

		{NULL,				NULL,												NULL,					REG_SZ,		NULL}
	};

	// First clear any old entries
	UnregisterServer();

	// Register the CLSID entries
	for(i = 0; ClsidEntries[i].hRootKey; i++) {
		wsprintf(szSubKey, ClsidEntries[i].szSubKey, szGUID);
		lResult = RegCreateKeyEx(ClsidEntries[i].hRootKey, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp);
		if (NOERROR == lResult) {
			TCHAR szData[MAX_PATH];
			// If necessary, create the value string
			if (ClsidEntries[i].type == REG_SZ) {
				wsprintf(szData, ClsidEntries[i].szData, szModule);
				lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)szData, (lstrlen(szData) + 1) * sizeof(TCHAR));
			} else {
				lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)ClsidEntries[i].szData, sizeof(DWORD));
			}
			RegCloseKey(hKey);
		}
		else
			return FALSE;
	}
	return TRUE;
}
int EXPORT PASCAL setupPlotHandler()
{
	unsigned int i;
	unsigned int j;
	int classIdx,levelIdx;
	boolean selectCellType;
	int retVal;
	boolean selectcellTypebyHetclass[MAXCLASSES];
	char tStr[255],tStr1[255], errStr[255];

	retVal = 0;
	//Init CNsave
	fprintf(logfile,"%s\tfunction:PlotHandler.setupPlotHandler\n", gettime());
	if (CNsave.cellcount != NULL)
	{
		free(CNsave.cellcount);
		CNsave.cellcount = NULL;
	}
	// set up the subsetting
	if (SubsetOption ==SUBSETSOMECELLSSELECTED)
	{
		//setup the subset
		numCellIndicesToPlot = 0;
		//initially allocate cellIndicesToPlot to MAXLOOKUPS
		cellIndicesToPlot = (unsigned int *)calloc(MAXLOOKUPS, sizeof(unsigned int));
		 if (cellIndicesToPlot == NULL)
		 {
			 sprintf(errStr,"setupPlotHandler: Out of memory, unable to allocate cellIndicesToPlot");
			 MsgBoxError(errStr);
		 }

		maxCellIndicesToPlot = MAXLOOKUPS;
		//for all possible celltypes
		for(i=1;i<=ntypes;i++)
		{
			 //initialize the boolean
			 for(j=0;j<(unsigned int)Number_of_Classes;j++)
			 {
			 	selectcellTypebyHetclass[j] = false;
			 }
			 selectCellType = true;
			 //check conditions
			 for(j=1;j<=numPlotSubset;j++)
			 {
				 levelIdx = getcelllevelbyclass(i,PlotSubset[j].classIdx);
				 //check is this celltype matches the subset class and level
				 if (levelIdx == PlotSubset[j].levelIdx)
				 {
					 selectcellTypebyHetclass[PlotSubset[j].classIdx] = true;
				 }
			 }
			 //if this celltype has matched atleast one subset condition for each class
			 for(j=1;j<=numPlotSubset;j++)
			 {
				 if( selectcellTypebyHetclass[PlotSubset[j].classIdx] == false)
				 {
					 selectCellType = false;
				 }
			 }
			 if (selectCellType == true) 
			 {
				 numCellIndicesToPlot++;
				 if (numCellIndicesToPlot >= maxCellIndicesToPlot)
				 {
					 maxCellIndicesToPlot += MAXLOOKUPS;
					 cellIndicesToPlot = (unsigned int *) realloc (cellIndicesToPlot , maxCellIndicesToPlot  * sizeof(unsigned int));
					 if (cellIndicesToPlot == NULL)
					 {
						 sprintf(errStr,"setupPlotHandler: Out of memory, unable to allocate cellIndicesToPlot");
						 MsgBoxError(errStr);
					 }

				 }
				 cellIndicesToPlot[numCellIndicesToPlot] = i;
			 }
		}
	}	

	//Allocate CNsave.cellcount, calculate numPlotLines
	switch(PlotOption)
	{
		case PLOTNOPROPSELECTED:
			CNsave.cellcount = (double *) calloc (2, sizeof(double));
			numPlotLines = 1;
			strcpy(PlotLineName[1],"Total Cellcount");
		break;

		case PLOTALLPROPSELECTED:
			CNsave.cellcount = (double *) calloc (ntypes+1, sizeof(double));
			numPlotLines = ntypes;
//			PlotLineName = (char *) calloc 
			for(i=1;i<=ntypes;i++)
			{
				strcpy(PlotLineName[i],"");
				construct_type_name(i,PlotLineName[i]);
			}
		break;

		case PLOTSOMEPROPSELECTED:
			//calculcate the number of lines
			numPlotLines=1;
			for(i=1;i<=numPlotProperty;i++)
			{
				numPlotLines = numPlotLines * Class[PlotProperty[i]].no_levels;
			}
			CNsave.cellcount = (double *) calloc (numPlotLines+1, sizeof(double));

			//Create Plot line names
			for(i=1;i<=numPlotLines;i++)
			{
//				PlotLineName[i] = (char *) calloc(255, sizeof(char));
				strcpy(PlotLineName[i],"");
				for(j=1;j<=numPlotProperty;j++)
				{
					classIdx = PlotProperty[j];
					levelIdx = getCellLevelbyClassforPlotting(i,j-1);
					if (Class[classIdx].class_type == MACRO)
					{
						get_macro_levelname(classIdx,levelIdx,tStr1);
					}
					else
					{
						strcpy(tStr1,Class[classIdx].Level[levelIdx].level_name);
					}

					if (j>1)
					{
						sprintf(tStr,"/%s",tStr1);
						strcat(PlotLineName[i],tStr);
					}
					else
					{
						sprintf(PlotLineName[i],"%s",tStr1);
					}
				}
			}
		break;
	}//end select
	return(retVal);
}