|
Take these with a grain of salt, I am no COM expert...
Question 1: I do not think that is directly possible, but I think that when you pass the interface pointer to another process (from B to A), you will get a marshalled interface pointer, which will not really be the same pointer value you passed over. Instead, it will be one that COM created during the "pass" operation. This new interface pointer will not be in B's address space, it will be in A's. If it pointed to a location in B's address space (for example, you passed over the value of the interface pointer), you would likely crash the instant you tried to use it because it would not point to the same location anymore (if it pointed anywhere valid at all).
Question 2: You have the FreeLibrary function, but you cannot get directly ahold of the handle for the DLL that contains the the InProc COM object*. It was loaded by the COM subsystem, and even if you did manage to get that handle and force an unload, I think you would be basically snatching the rug out from under COM and that might be bad...
* Yes, you could call LoadLibrary again and might get the same instance handle...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
inner wrote:
Can A actualy call C which is in B process space?
I'm pretty sure you can't do this. Sharing of a COM object must be managed by the object itself.
inner wrote:
Is there a way to force it to unload?
Not easily. Is there any reason why you'd want to though? Windows manages this quite well.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi all,
I am using FindFirstFile and FindNextFile to read a folder and get all files properties.
There is a problem. That two functions are reading files and folders sorted by name.
I mean,
c:\test
c:\test\a.txt
c:\test\c
c:\test\c\m.txt
c:\test\k.txt
I'm wondering if I can sort before I read it?
Like sorting file name or size or extension before I read it?
c:\test
c:\test\a.txt
c:\test\k.txt
c:\test\c
c:\test\c\m.txt
|
|
|
|
|
|
For NTFS volumes, the files/folders are enumerated in sorted order. For non-NTFS volumes, the files/folders are enumerated in the order in which they were added. That said, you'll need to add all files/folders into an array, sort the array, and then process it.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Wouldl it make sense to have two code paths, then? One for NTFS and one for others? The NTFS would be optimal, no sorting required. Other storage types could use the slower method
|
|
|
|
|
Blake Miller wrote:
Wouldl it make sense to have two code paths, then?
Given how fast a data structure can be sorted, I would think not.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I really need some help with this one. I have wasted too much time and not made much progress.
What I am trying to do is to read a timestamp from index.dat generated by Internet Explorer. The timestamp is in the file in the following format "00 14 AC 72 BE 95 C2 01". A document I read takes the value and reverses the order so that the value is "0x01C295BE72AC1400" and then passes it into the w32tm function as follows: "w32tm /ntte 0x01c295BE72AC1400" and gets a return of "146792 02:41:12.0000000 11/26/2002 8:41:12 PM (local time)". I'm trying to accomplish this within my Visual C++ program but just can't get it. I'm certain there are others out there who are smarter and more experienced when it comes to such issues. I just want to be able to read the data from the file and pass it into asctime to get a meaningful date and time stamp.
Does anyone know how to accomplish this?
Many Thanks
|
|
|
|
|
If you know VB, you might take a peek at the ie.vbs file that accompanies this article.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi,
I don't know if this is the appropriate forum for this question, but I don't know any other place to post it. I have a Windows service in which I have an embedded binary resource that I want to load at service startup. However, the API functions below fail with an exception or return NULL:
Both of these calls throw an exception when called by my service:
HINSTANCE hInstance = AfxGetInstanceHandle();
HINSTANCE hInstance = AfxGetResourceHandle();
This always returns a NULL when called by my service:
CWinApp* lpApp = AfxGetApp();
hInstance = lpApp->m_hInstance;
How can I access this resource?
Thanks,
Royce
|
|
|
|
|
This might sound like a stupid question, but is it an MFC-based service? For example, if this is an ATL-based service, functions like that will fail because you are likely to not have a real MFC CWinApp around.
You DID check the pointer returned by AfxGetApp to ensure that it is not NULL right?
Move away from the MFC-based resource functions and take a look at the native Win32 ones, like FindResourceEx(...) and LoadResource if you have no useful MFC "state" available in your service.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
James,
Thanks for your help. No, it is not a stupid question. I should have said that it is a MFC-based service. I tried FindResourceEx() and LoadResource() API functions. They return NULL. AfxGetApp() returns a valid (?) pointer, but the member m_hInstance is NULL. This problem is complicated by the fact that this resource is an encryption key and password and is used by two other applications and numerous DLLs. Difficult to understand, let alone explain to someone else.
Thanks,
Royce
|
|
|
|
|
Have you tried calling FindResourceEx with a NULL instance parameter directly? Also, try using FindResource if language is not an concern (and it sounds like it is not).
Also, how are the resources identified, by number or by string? Are you using the correct Resource Type value?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Yes, I tried FindResourceEx() with the NULL instance parameter. The resources are identified by number, their type is "TEXT".
|
|
|
|
|
Are you using MAKEINTRESOURCE to specify the identifying number?
This might go faster if we had a code snippet of the code you are using...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
This code fails - the m_hInstance member is null:
CWinApp* lpApp = AfxGetApp();
HINSTANCE hInstance = lpApp->m_hInstance;
This code fails - fires an assert in debug, throws an exception in release version:
HINSTANCE hInstance = AfxGetInstanceHandle();
This code never executes because of the above failures:
HANDLE hHandle1 = LoadResource( hInstance, FindResource( hInstance, MAKEINTRESOURCE( IDR_RES1 ), "TEXT" ) );
HANDLE hHandle2 = LoadResource( hInstance, FindResource( hInstance, MAKEINTRESOURCE( IDR_RES2 ), "TEXT" ) );
This code works in 3 other Windows desktop applications. It just doesn't work here because of the runtime environment, the service. I am trying to find a way around the fact that the embedded resources aren't accessible when the service is loading, or even after it is loaded.
Thanks for your help,
Royce
|
|
|
|
|
If your resources are contained directly within your EXE file, then use GetModuleHandle(NULL) to retrieve the 'instance' handle used for loading the resources
|
|
|
|
|
When you said an "MFC based service" before, do you really mean a MFC service, or an ATL service with "support MFC" checked. If you have the latter, you need to "fool" MFC by doing the following:
CWinApp waWA;
waWA.m_hInstance = _Module.GetModuleInstance();
afxCurrentInstanceHandle = _Module.GetModuleInstance();
afxCurrentResourceHandle = _Module.GetResourceInstance();
Then things that refrence the global CWinApp instance will work correctly. Kludgy, but that is what you get for mixing MFC and ATL with VC++ 6.0!
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
No, there is no ATL support in this project.
|
|
|
|
|
GetModuleHandle(NULL) returns 0x00400000, which is not a valid handle.
|
|
|
|
|
Have you tried using it? Even if it was invalid, using FindResource(...) with a NULL hModule parameter should default to using the load image (EXE).
Are the resources present in the executable itself, and not in another DLL? Are you sure they are being linked in correctly? One way to test is to open a new instance of DevStudio, and open the EXE file being sure to specify "Resources" in the "Open As" combobox. You can them be sure that the resources are actually there and accessable - you should be able to double-click on them and see them in the binary editor.
I am running out of ideas here...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Yea, so am I! Yes, when I use the invalid handle, I just get another null.
|
|
|
|
|
Yes, the resources are in the EXE. I have opened the EXE in binary mode with the IDE's resource editor and I can see them.
|
|
|
|
|
while trying to use GetTextExtentExPoint function I get the following error during compilation:
c:\Documents and Settings\Admin\My Documents\Visual Studio Projects\InfoBrowser\InfoBrowserView.cpp(387): error C2039: 'GetTextExtentExPointI' : is not a member of 'CDC'
But according to the "manual" it should be a member...
Just to be complete I am sending part of a code:
void CInfoBrowserView::drw_DVDDetail(CDC* pDC)
{
pDC->TextOut(rect_DVDDetail.left,rect_DVDDetail.top,"Název:");
pDC->GetTextExtentExPointI();//the parameters are missing, but that shouldn't affect the error...
}
thanks for any elp
|
|
|
|
|
webmaster1234463653 wrote:
But according to the "manual" it should be a member
which version of VC++ are you using?
the MSDN for VS.Net lists it as a member of CDC, but the MSDN for VC6 doesn't have it.
this might have been added in MFC 7
-c
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|