|
You only need to call FindFirstFile() once, after that, call FindNextFile()
|
|
|
|
|
LCI wrote: while (hfind = FindFirstFile(TEMP,&FindFileData))
{
if (hfind == INVALID_HANDLE_VALUE)
break;
//Do some stuff with the file
}
Instead try the following
hfind = FindFirstFile(TEMP, &FindFileData);
if(hfind != INVALID_HANDLE_VALUE)
{
do
{
// Do some stuff..
hfind = FindNextFile(hfind, &FindFileData);
}while(hfind != INVALID_HANDLE_VALUE);
}
Cheers,
Suresh
|
|
|
|
|
Can anyone please help me or give me some sample code? I need to create an ATL COM service which has a dummy interface.. say. add 2 numbers.. After creating the service, i want to register it as a windows service. Then i want to create a client which connects to this service and uses the interface.. (adds 2 numbers)
I have searched online and there is not a decent article which explains the process step by step... Any help in this regard will be very useful.
Thanks in advance!!!!
|
|
|
|
|
Hi,
Create a ATL Project and choose service(EXE) type. The Wizard will generate code for you.
Add an ATL Simple object Like as you add ATL Simple Object to any ATL Project.
Implement your dummy methods or what ever you want.#
Build the project, Go to command prompt and type <exe name> -i to Install it as a Windows service.
In Client you can do a #import on this executable and you can use your dummay interface and methods.
Cheers,
Suresh
|
|
|
|
|
I have succeded in creating a service with a dummy interface.... Then in the client I have imported the header file of the service and defined the GUID's. Suppose i have an interface IFirst_ATL and it has a method addnumbers(), then how can i access that method. I am trying to create an instance of the service by
hr = CoCreateInstance( CLSID_First_ATL, NULL, CLSCTX_INPROC_SERVER,
IID_IFirst_ATL, (void**) &IFirst_ATL);
IFirstATL->AddNumbers(5, 7, &ReturnValue);
but this is not giving me the desired results. Can you please provide me a sample and successfully running code for accessing the methods of the service?
Thanks in Advance!
|
|
|
|
|
Seems that i have found out the problem.. I replaced CLSCTX_INPROC_SERVER with CLSCTX_LOCAL_SERVER in CoCreateInstance(). But now i am facing a different problem.
I have defined a method in my interface as.
STDMETHODIMP CFirst_ATL::AddNumbers(LONG x, LONG y, LONG* z)
{
*z = x + y;
return S_OK;
}
when i try calling this method from client as
hr = IFirst_ATL->AddNumbers(5, 7, &ReturnValue);
the method returns S_OK, but the value in ReturnValue is some garbage value. Can anyone please advice where have i went wrong?
Thanks!
|
|
|
|
|
VS2005 seems to prevent you from adding ATL Dialog class from the wizard. I found a work-around:
1.
DEFINE_GUID(LIBID_ATLDelmeLib,
0x288cd07e, 0x98a4, 0x4259, 0x9f, 0x38, 0x99, 0xaf, 0xc8, 0xa, 0xd0, 0x6e);
class CATLDelmeModule : public CAtlExeModuleT< CATLDelmeModule >
{
public :
DECLARE_LIBID(LIBID_ATLDelmeLib)
DECLARE_REGISTRY_APPID_RESOURCEID((UINT)0, "{288CD07E-98A4-4259-9F38-99AFC80AD06E}")
};
CATLDelmeModule _FakeAtlModule;
CAppModule _Module; 2.Use Project->Add Class, to add your new dialog class. Notice how VS2005 seems to agree with us now!
3.Comment back the line CATLDelmeModule _FakeAtlModule; if not it will conflict
Looking at '/VC/VCWizards/1033/common.js' can guide your for a few more trick.
Software Development Is Decision making.
|
|
|
|
|
Hello,
I need to use a map to stock inforamtion that containt 2 int like
class y;
class x
{
int a;
int b;
bool operator< (const x& w) const {
CString strthis;
CString strother;
strthis.Format("%d_%d",a,b);
strother.Format("%d_%d",w.a,w.b);
return (strthis<strother);
}
My operator that I have programed work but, I know that the solution is very bad and not very efficient.
How can I make a good operator < or were can I found some sample to learn about programing operator
Thank for help
AutreChien
|
|
|
|
|
NorGUI wrote: How can I make a good operator < or were can I found some sample to learn about programing operator
Well, there's nothing wrong with the declaration of the operator.
You should consider how negative values of x::a and x::b should be treated.
Your implementation may not give the result you expect if either of the variables were found negative.
Regarding how to make the operator more efficient you can try the following:
bool operator<( const x& w ) const
{
bool bResult = false;
if( a == w.a )
{
bResult = (b < w.b);
}
else
{
bResult = (a < w.a);
}
return bResult;
} This is how I think you want your operator to work given the code snippet you posted. It uses the integer values and saves the detour using CString which is quite expensive.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I have a class
template<class T>
class foo()
{
template<typename T> friend ostream& operator<< (ostream& os, TestTemplateCollection<T>& r)
{...
}
int main(int argc, char * argv)
{
foo<T>;
foo<B>; //error c2995 operator<< allready defined
}
order doesn't matter both T and B work without the other is there something special you must do to friend template classes work. I do have the header in cased in a #pragma once statmen so its not in the preprocess output twice.
-- modified at 22:08 Tuesday 17th April, 2007
a programmer traped in a thugs body
|
|
|
|
|
I fixed this.
If any one wants to know
friend function of template classes should be defined outside the class definition but in the header file or you liker will crap its pants.
a programmer trapped in a thugs body
|
|
|
|
|
I have native C++ XMLTranslator (dll) built using VC8 compiler in VS2005 IDE.
This dll basically imports msxml4.dll as shown below:
#import "msxml4.dll" named_guids implementation_only
When native clients using VC6 compiler link to my XMLTranslator.lib I found below linker errors in imports:
XmltxtorTest.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class _com_ptr_t<class _com_iiid<struct="" msxml2::ixmldomdocument2,&struct="" __s_guid="" _guid_2933bf95_7b36_11d2_b20e_00c04f983e60=""> > __thiscall altova::CDoc::Load
FromString(class std::basic_string<unsigned short,struct="" std::char_traits<unsigned="" short="">,class std::allocator<unsigned short=""> > const &)" Debug/XmltxtorTest.exe : fatal error LNK1120: 2 unresolved externals
The export signature of VC8 dll:
class _com_ptr_t<class _com_iiid<struct="" msxml2::ixmldomdocument2,&struct="" __s_guid="" const="" _guid_2933bf95_7b36_11d2_b20e_00c04f983e60=""> > altova::CDoc::LoadFromString(class std::basic_string<unsigned short,struct="" std::char_traits<unsigned="" short="">,class std::allocator<unsigned short=""> > const &)
Basically the difference I found is the word "const" between imports and exports.
VC8 compiler exports additional const key word in whereas VC6 compiler doesn't expect const key word during imports.
How to make msxml exports/imports compatible across VC6 and VC8 compilers??
Thank you so much for any help in this aspect. I have been trying to get around this problem over a week.
Thanks again & Regards,
-- modified at 13:29 Tuesday 17th April, 2007
|
|
|
|
|
LIBs are not backward-compatible, since any version of the compiler/linker can change internal details that end up breaking compat with older linkers. You'll need to build a LIB yourself using VC 6.
|
|
|
|
|
Now i have lots of text files in a folder,i want to combine them into one large file,but the problem is that it is must be order the formation rule.
for instancethe txt file order)
the first text file list item"1c.txt,2c.txt,.........
the second text file list item"1e.txt,2e.txt,........
now the combine file order must be "1c.txt,1e.txt,2c.txt,2e.txt........."
and so on!
I want use STL implicat it!
Waiting for ur help!
Thx advance!
Where did the good times go?
Don't try it, just do it!
*Archibald*rever dragon!
|
|
|
|
|
Amidst of development of toolbar, a requirment came to colour toolbar.
As we can colour explorerbar easily with OnPaint, we can colour the
toolbar also,but after colouring the Toolbar buttons Vanish. Code is totally
based on ATL\ COM and not MFC.
The reason I found is NM_CUSTOMDRAW not getting called . Even if I
post the message WM_ERASEBKGND.
Can anyone tell how to overcome this problem. Even if we call
TB_INSERTBUTTON at end of OnPaint it does not prove fruitful.
-- modified at 8:38 Monday 16th April, 2007
|| ART OF LIVING ||
|
|
|
|
|
Purpose is to prevent writing sensitive data to hard drive, so after shutting down the computer, sensitive data will be lost (in RAM) THANKS A LOT FOR YOUR REPLY
marcelse
|
|
|
|
|
Hi.
Let us say, we have a banner on some site, embedded as a flash object. In my BHO I need to catch some events from this banner. I do this way:
1. Wait until the document is completed.
2. Enumerate all OBJECT elements.
3. On the needed element perform this:
Code:
<br />
CComQIPtr<IHTMLObjectElement> pObj=pElem;<br />
CComPtr<IDispatch> pD;<br />
pObj->get_object(&pD);<br />
if (pD==NULL) return;<br />
CComObject<CFlashSunk> *sink;<br />
sink=new CComObject<CFlashSunk>();<br />
<br />
CComQIPtr<IConnectionPointContainer> pCont;<br />
HRESULT hr;<br />
pCont=pD;<br />
CComPtr<IConnectionPoint> pPoint; <br />
hr = pCont->FindConnectionPoint(ShockwaveFlashObjects::DIID__IShockwaveFlashEvents, &pPoint);<br />
if (FAILED(hr)) return;<br />
DWORD dwCookie;<br />
hr = pPoint->Advise((ShockwaveFlashObjects::_IShockwaveFlashEvents *)sink, &dwCookie);<br />
if (FAILED(hr))return;<br />
4. Here the class CFlashSink:
<br />
#import "C:\\WINDOWS\\system32\\Macromed\\Flash\\Flash.ocx" named_guids <br />
<br />
#include "Debug\Flash.tlh"<br />
<br />
class ATL_NO_VTABLE CFlashSunk :<br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CFlashSunk>,<br />
public IDispatchImpl<ShockwaveFlashObjects::_IShockwaveFlashEvents, &ShockwaveFlashObjects::DIID__IShockwaveFlashEvents,&ShockwaveFlashObjects::LIBID_ShockwaveFlashObjects> <br />
{<br />
<br />
public:<br />
<br />
<br />
BEGIN_COM_MAP(CFlashSunk)<br />
COM_INTERFACE_ENTRY(IDispatch)<br />
COM_INTERFACE_ENTRY(ShockwaveFlashObjects::_IShockwaveFlashEvents) <br />
END_COM_MAP()<br />
<br />
<br />
<br />
STDMETHOD(Invoke)(DISPID, REFIID, LCID, WORD, DISPPARAMS*,VARIANT*, EXCEPINFO*, UINT*); <br />
<br />
<br />
<br />
<br />
STDMETHOD(OnReadyStateChange) (long newState); <br />
STDMETHOD(OnProgress) (long percentDone);<br />
STDMETHOD(FSCommand) (BSTR command, BSTR args);<br />
STDMETHOD(FlashCall) ( BSTR request);<br />
};<br />
Problem: neither in Invoke nor in FSCommand nothing comes at all!
Where is the trouble ?
|
|
|
|
|
HOW TO SEND AND RECEIVE SMS BY PC
I WILL BE THE FIRST
|
|
|
|
|
hi,
Can any body tell to me, how i add a checkBox in MMC snapin(Throught ATL)in result Pane.Plz help me.
thanks in advance....
Monica
|
|
|
|
|
I am using the command line to pass values. The values are numbers or "ni" for negative infinity (& pi for positive).
This is my code:
if (argv[1] == "ni")
But it fails. It never evaluates to true . Why is this? "ni" is a char array and so is argv[], is it just me or is something going on.
I tried this on Windows and Unix and the same thing happened.
Download here[^] for the full source
|
|
|
|
|
That's not how you compare C-style strings. Use strcmp() instead.
|
|
|
|
|
yes, i fixed the problem. I just converted to string.
I forgot that C-strings are just pointers, so you are actually comparing the memory locations. However, i could have sworn i had seen it written before (unless it was to specifically compare memory locations)
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
We have built a com based application in VC5, VC6 in debug mode & works fine.
when migrated to VC++ 8.0, com register class is failing.
VC6 binary is built which atl6.0.dll and works fine. but when the application is built with atl8.0 com register class is failing.
We are using CComModule class in atl6.0. But it looks like the same class is change to CAtlComModule in atl8.0
Is there any option which will enable backward comptible in atl8.0?
Thanks
|
|
|
|
|
You need to read the documented breaking changes that have been put in effect in ATL version 7. There were very few notable changes from 7 to 8! CComModule was replaced with several different module classes: CatlModule, CatlExeModuleT, CatlDllModuleT and CatlServiceModuleT. According to "ATL Internals", Second Edition, page 811:
<quote>..., there's not much to be gained in removing your ATL 3 modules and replacing them with the ATL 8 modules when you migrate your project. ... If you need (...) to rewrite the module-related code in your ATL 3 server to match and ATL 8 server, your best bet is to run the new VS05 wizard with the names and settings you need and then move over your ATL 3 classes.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I need to convert a UTF8 string (stored in a std::string) to a UTF16 string (and store the result in a std::wstring) and vice-versa, in a portable way (so ::MultiByteToWideChar, etc. are out of the question). Anyone have any tips, pointers to samples, etc.? I am currently porting a Windows app to Linux (!) which uses the STL/Boost, and this is one area where I would appreciate some advice.
|
|
|
|
|