Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

act_x

@act_x
About
Posts
356
Topics
239
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • COM unable to obtain interface -
    A act_x

    I was able to modify my client code to do this

    if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
    {

    	HRESULT  res = CoGetClassObject(g\_MycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)&pClassFactory );
    
    	if(SUCCEEDED(res))
    	{
    		// res  = pUnknown->QueryInterface(IID\_IAdd,(void \*\*)&pAdd);
    		res = pClassFactory->CreateInstance(0,IID\_IAdd , (void \*\*)&pAdd);
    		pClassFactory->Release(); 
    	}
    	else if(res == E\_NOINTERFACE )
    	{
    		int x = 1; 
    	}
    	else if(res == E\_INVALIDARG)
    	{
    		int r = GetLastError() ; 
    	}
    	CoUninitialize(); 
    }
    

    The call to

    HRESULT res = CoGetClassObject(g_MycfgCLSID , CLSCTX_ALL , NULL , IID_IClassFactory , (void **)&pClassFactory );

    succeeds providing a pointer to IClassFactory However this line

    res = pClassFactory->CreateInstance(0,IID_IAdd , (void **)&pAdd);

    returns the following error

    #define REGDB_E_IIDNOTREG _HRESULT_TYPEDEF_(0x80040155L)

    Engineering is the effort !

    C / C++ / MFC com sysadmin help

  • COM unable to obtain interface -
    A act_x

    I have some COM client code that I am trying to write

    IAdd \*pAdd = NULL ; 
    IClassFactory \*pClassFactory= NULL  ; 
    IUnknown \*pUnknown = NULL ; 
    
    if (SUCCEEDED(CoInitializeEx(NULL, COINIT\_APARTMENTTHREADED)))
    {
    	HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL   , IID\_IUnknown , (void \*\*)&pUnknown);
    	//res = pUnknown->QueryInterface(IID\_IAdd , (void \*\*)pAdd);
    
    	 res = CoGetClassObject(g\_MotAutoplaycfgCLSID , CLSCTX\_ALL , NULL , IID\_IClassFactory , (void \*\*)pClassFactory );
    	if(res == E\_NOINTERFACE )
    	{
    		int x = 1; 
    	}
    	else if(res == E\_INVALIDARG)
    	{
    		int r = GetLastError() ; 
    	}
    }
    

    I can get this to retrive a valid pointer for pUnknown

    	HRESULT res = CoCreateInstance(g\_MotAutoplaycfgCLSID , NULL , CLSCTX\_ALL   , IID\_IUnknown , (void \*\*)&pUnknown);
    

    However I am unable to obtain the interface Handle to IAdd Interface. On the Server Side I can see that the ClassFactory class is created and that the Coclass is also instantiated. Help is appreciated

    Engineering is the effort !

    C / C++ / MFC com sysadmin help

  • Unable to find definition for CComCriticalSection class
    A act_x

    Hi , I have a simple File - logging class which I plan to use in a COM Server. I also have a template based Singleton Class ( CSingleTonT) that takes this object such that there is only 1 instance of this in the system. I am trying to add a CComCriticalSection protected member variable and inspite of including the header for this I am getting a compilation error #ifndef _CLOGGER_H #define _CLOGGER_H #include "atlbase.h" #include "atlcore.h" .. .. class CLogger { public : // All methods here protected : bool m_bInitialized ; ofstream m_logfile; CComCriticalSection myCS ; string strFileName ; }; Now these are the compilation errors I get

    1>d:\code\com\clogger.h(172) : error C2146: syntax error : missing ';' before identifier 'myCS'
    1>d:\code\com\clogger.h(172) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>d:\code\com\clogger.h(172) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    The definition for CComCriticalSection exists in atlcore.h which is included . Any help is appreciated

    Engineering is the effort !

    C / C++ / MFC help c++ com sysadmin

  • Getting handle of hidden window from another process
    A act_x

    I have an EXE that has a hidden window. Is it possible to obtain a handle to this window and post a WM_QUIT message. The basic requirement that I have is that I need to un-install an application and before the process of un-install , I need to kill the process .

    C / C++ / MFC

  • Custom action DLL for Windows Installer
    A act_x

    I am trying to invoke a Win32 DLL from the Windows Installer to perform certain custom actions. For this purpose I have exposed 1 API

    MY_DLL_API UINT MyCustomActionLaunch(MSIHANDLE hMsiModule)
    {

    MessageBoxW (NULL, L"MyCustomAction launch", L"MyCustomAction", MB\_OK);	
    WCHAR msg \[500\] = {0};
    WCHAR vbuff \[1024\] = {0};
    DWORD vlen = 1024;
    UINT gp = MsiGetPropertyW(hMsiModule, L"ProgramFilesFolder", vbuff, &vlen);
    
    **if(gp == ERROR\_SUCCESS )
    {
    	 if (wcslen(vbuff) <= 0)
    	 {
    		 MessageBoxW(NULL , L"Zero Bytes",L"MyCustomAction" , MB\_OK);		 }
    	
    	MessageBoxW(NULL, vbuff, L"MyCustomAction", MB\_OK);    		
    
    }**	else
    {
    	MessageBoxW (NULL, L"Failure", L"MyCustomAction", MB\_OK);
    
    }
    
    return -1;
    

    }

    I find that no bytes are being copied, where I am querying for a standard property . This DLL is being developed in VC6. Does anyone see anything wrong here ?

    Engineering is the effort !

    C / C++ / MFC json help question

  • Service or Singleton COM exe or DLL
    A act_x

    Hi , I have a requirement , where I want one entity to be persistent in the computer. I am struggling to decide on what this entity will be . My model is such that I want to be able to intercept USB device notifications utilizing the WM_DEVICE_CHANGE messages by creating a hidden window in this entity and then update the elements of a system tray icon ( which exposes a Menu ) . So my requirement does not fit the Client Server model , yet I am leaning towards COM to provide one EXE that does it all . So in other words , this entity will not provide any APIs for other clients to use . Am I unnecessarily using COM ? So finally I need to finalize the form that this need to take . Service - actually the Visual Studio 6 gives the option to create a COM Object as a Service. COM DLL COM EXE Standalone EXE ? Your inputs are really appreciated

    Engineering is the effort !

    C / C++ / MFC csharp visual-studio com sysadmin question

  • Windows Service
    A act_x

    I am a total stranger to windows service development. I needed to understand the limitations . 1. Is it possible to have MFC support in Service code? 2. Can I create a hidden window in a Service ? My basic requirement is to intercept WM_DEVICE_CHANGE notifications to process this message.

    Engineering is the effort !

    C / C++ / MFC c++ question

  • loading registry file programatically
    A act_x

    thanks for steering me into resolving this . The key was to enclose the file path in quotes before supplying it to regedit. But I wonder why and how this would be different in a DLL that I developed .

    Engineering is the effort !

    C / C++ / MFC help com windows-admin oop workspace

  • loading registry file programatically
    A act_x

    so basically I am trying to create a process to run

    regedit /s C:\Program Files\Common Files\MyApp\1.reg

    For debugging purposes I removed the /s for regedit and I see that it chops the path by space So it keeps asking if I want to enter the entry C:\Program Files Common Files\MyApp\1.reg Is there a way this can be prevented ? These files are present in the current working directory of the exe and pro grammatically obtained via GetModuleFileName

    Engineering is the effort !

    C / C++ / MFC help com windows-admin oop workspace

  • loading registry file programatically
    A act_x

    I attempted to do this in a DLL and it worked just fine . However moving the code inside COM exe does not report any error but does not load the information in the registry .

    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    	ZeroMemory( &si, sizeof(si) );
    	si.cb = sizeof(si);
    	ZeroMemory( &pi, sizeof(pi) );		
    	//strLocalFileName = "/a " + strLocalFileName;
    	CString strLocalFileName = CString(\_T("regedit.exe /s ")) + strRegFileName;
    
    		// Start the child process. 
    	if( !CreateProcess(  NULL,   // No module name (use command line)
    		strLocalFileName.GetBuffer(0),      // Command line
    		NULL,           // Process handle not inheritable
    		NULL,           // Thread handle not inheritable
    		TRUE,          // Set handle inheritance to FALSE
    		NORMAL\_PRIORITY\_CLASS,              // No creation flags
    		NULL,           // Use parent's environment block
    		NULL,           // Use parent's starting directory 
    		&si,            // Pointer to STARTUPINFO structure
    		&pi )           // Pointer to PROCESS\_INFORMATION structure
    	) 
    	{
    		//AfxMessageBox("Error Creating Process");
    		int error = GetLastError() ;
    		CloseHandle(pi.hProcess) ; 
    		return false ; 
    	}
    	else
    	{
    		ATLTRACE("GetLastError = %d\\n",GetLastError()); 
    		WaitForSingleObject( pi.hProcess, INFINITE );
    		DWORD dwCode = 0; 
    		GetExitCodeProcess  (   pi.hProcess,    &dwCode);
    		CloseHandle(pi.hProcess); 					
    
    	}
    

    Any help is appreciated !

    Engineering is the effort !

    C / C++ / MFC help com windows-admin oop workspace

  • specifying object type at compile time
    A act_x

    given a class heirarch where A is the base class and B , C are derived classes . Now I want to implement something like an object factory externally where I want to automatically create an object of the appropriate type . For this I define a struct with the definition ( pardon me for the pseudo code as part of the problem is with usage)

    typedef struct 
    { 
      int code ;
      reference_to_type_creator ; 
    }OBJ_TYPE ; 
    
    OBJ_TYPE objTable[] = 
    { objA_code  , < reference to create an object of type A > } , 
    { objB_code  , < reference to create an object of type B > } , 
    { objC_code  , < reference to create an object of type C > } , 
    
    { -1 , NULL } 
    

    such that I can use this table in a function that processes random object entries

    ProcessObject( int objCode  )
    {
    for (int i=0;objTable[i].code!=-1;i++)
    {
        if( objCode == objTable[i].code)
       {
          A *a = objTable[i].reference_to_type_creator     // Unsure about how this could work 
          a->Foo()
       }
    }
    }
    

    I was unclear as to how this reference would be specified in the struct array above and its usage. Help is appreciated }

    Engineering is the effort !

    C / C++ / MFC help data-structures lounge

  • associating tray icon with app
    A act_x

    I know this sounds like a hijack , however I would need to associate my application , with the system-provided , Autoplay notification icon . In other words is it possible to 1. pop-up a custom menu when the user clicks this icon ? 2. Perform custom actions with each of the menu items ? I dont want to create another tray icon as my use case is related to this sys tray icon . eg: When a camera is connected and the icon is present, I would want to provide menu options to open the folder to view the files

    Engineering is the effort !

    C / C++ / MFC question

  • silently installing .reg file
    A act_x

    From my application , I need to load the contents of a reg file programmatically . I have tried to use Shellexecute supplying the filepath to the reg file however it still prompts me by asking if i need to insert the file into the registry. I would want to do this silently as the regedit /s option does it silently. thanks

    Engineering is the effort !

    C / C++ / MFC windows-admin

  • constructor / destructor in template class
    A act_x

    ahh that was silly. Sorry for bothering u guys . Never thought it was an access issue !

    Engineering is the effort !

    C / C++ / MFC help question

  • constructor / destructor in template class
    A act_x

    template class CProtectedVariable { CProtectedVariable() { } ; ~CProtectedVariable() { } protected : T m_Var ; } ; when i do this and include this another class as a member. I am getting a few compiler errors #include "Protected.h" class OutSideClass { protected : CProtectedVariable m_initState ; }; error C2248: 'CProtectedVariable::CProtectedVariable' : cannot access private member declared in class 'CProtectedVariable' 1> with 1> [ 1> T=bool 1> ] What am I missing here ?

    Engineering is the effort !

    C / C++ / MFC help question

  • extracting icon from exe or DLL
    A act_x

    How can this be done ?

    Engineering is the effort !

    C / C++ / MFC question

  • Systemtray
    A act_x

    is it possible to have a standalone system tray icon without an exe ? Typically an exe exposes a System tray icon . However my requirement is such that I would want to launch an app after the user selects an element from the system tray. Is this feasible ? For some of the icons (such as the LAN/Network status ) , I do not see a corresponding application in the taskbar. How are these implemented ?

    Engineering is the effort !

    C / C++ / MFC sysadmin question

  • resizing a property sheet
    A act_x

    This , I thought would be simple. I have spent close to half a day figuring this out . So I am working on a MFC dialog app that has a CPropertySheet object. I am using the property sheet in Non Wizard mode. MyDlg::OnInitDialog(.) { .. CPropPage1 *pPage = new CPropPage1() ; m_sheet.AddPage(pPage); //m_sheet.DoModal(); if(!m_sheet.Create(this,WS_CHILD | WS_VISIBLE |WS_BORDER)) return FALSE ; m_bInitialized = true ; } I am unable to size the propertyPage to fit the dimensions of the main dialog window. What should I be doing to ensure that the current active page in the PropertySheet is contained within the bounds of the Main dialog . This is how my dialog looks at this point ( awful ! :() http://i25.tinypic.com/2mhiob8.jpg Help is appreciated

    Engineering is the effort !

    C / C++ / MFC c++ com help

  • Determine if an exe is running or not
    A act_x

    1 )I am implementing a component that receives an event , which needs to launch an exe However , I do not want to launch the exe if it is already running . Is there a way to determinie if the exe is currently running ? 2)Typically there are applications that are launched the first time when an event occurs . Say Windows media player is launched when i connect my music player However I would want to understand how these applications get notified when subsequent events ( non-first time events ) occur ? Is there a standard pattern to follow ? I was thinking, more on the lines of the App ( such as Windows Media player) that acts as a client to a Com Server ( which receives the notifications) , however the non first time notifications would be conveyed via a callback ( registered during initialization of the EXE ) . Ideas are welcome Thanks

    Engineering is the effort !

    C / C++ / MFC com sysadmin regex question

  • Creating stellar GUI
    A act_x

    I am not sure if this is the exact topic to post here however I thought I'd give it a try. I have been coding MFC for a few years. The look and feel of the GUI's (that I create ! :() ( Dialog based app) seems ( to me ) to look very ordinary . Sometimes when you demo stuff to customers , part of the deal is to create "Flash" like GUI's that actually have the same functionality of an engineering application ( normally coded using MFC, C++). Customers most often get "wowed" by the new , cool , look and feel instead of the usual gray dialog with buttons and edit boxes. I am in search of something ( library / component(s)) that can still preserve the ease of coding in MFC/C++ but exposes a whole new world of creating stunning GUI ( rich in color and action ). I would appreciate if someone could provide ideas for achieving this .

    Engineering is the effort !

    C / C++ / MFC c++ adobe
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups