|
Thx's i found exception
a.exe: 0xC00000FD: Stack overflow.
Following exception occurred: -1073741571 -- File: e:a\delayeddirectorychangehandler.cpp Line: 229
And line is here..
TRACE(_T("Following exception occurred: %d -- File: %s Line: %d\n"), dwEx, _T(__FILE__), __LINE__);
I am useing directorywatcher and take example from codeproject.Lunk is here http://www.codeproject.com/KB/files/directorychangewatcher.aspx[^]
plz help me
|
|
|
|
|
Please follow Rajesh's advice and use GetLastError().
|
|
|
|
|
knowvc wrote: I have problem
Which is ? How can we help you if you don't provide enough information ?
Did you check that "a.txt" doesn't exist (you are passing TRUE for the bFailIfExists parameter) ?
knowvc wrote: CopyFileA
Why are you using the version specific to non-UNICODE builds ? You should use CopyFile instead.
|
|
|
|
|
Hello everyone,
When in the ATL wizard to create a coclass, we specify ProgID under COM category.
My questions,
1. I think the progid could be used by COM consumer/client to create COM object instance without using GUID/CoClass name, and just use progid. And progid is for each coclass level, not for interface or for COM server level. is that correct?
2. I am taking quite some time in MSDN and Google to find a simple sample of how to use progid to create coclass object. Could anyone refer some sample pleases?
3. Besides using progid to create a coclass, any other usages?
thanks in advance,
George
|
|
|
|
|
|
Thanks Sohail,
You have made a so great reply! Very comprehensive!
Two more questions,
1.
Normally how will COM comsumer know progid? From typelib file, IDL file or from some other means?
2.
Each progid is for each coclass type (e.g. suppose in my in-process server DLL, I defined 5 coclas types, then I should have 5 progids?), and progid is not for interface or in-process server DLL, correct?
regards,
George
|
|
|
|
|
1. Normally some information will be required by consumer of your COM server. So ProgId, ClassId, Interface descriptions etc need to be published. There are various ways for the consumer to instantiate and consume the services provided by the COM Server (one of which is using ProgId). If information from TypeLib is to be queried then you may use Type Description Interfaces and Functions[^]. There is also IProvideClassInfo[^] interface that helps accessing the type information for an object's coclass.
ProgId could be published in TypeLib files, Interface and coclass declaration (header) files or simply as part of your COM server documentation.
2. Yes. As mentioned by Larry Osterman in his blog entry (see the link I posted earlier) - "The PROGID provides the ability to define a string alias for a particular COM object. Thus with the PROGID, you can access a COM object without having to know it's CLSID. This can be quite handy, especially when you're working in languages that don't provide easy access to a GUID data type. A PROGID is simply a string representation of the class. "
Glad I could help.
PS: What registry entries are needed to register a COM object[^] is a good read.
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Cool Sohail!
Two more comments,
1. Besides using progid to create a coclass by getting CLSID, any other usages?
2. Is it possible there are conflicting progid string? My concern is GUID generation algorithm is well-defined to avoid conflicting, but for progid, it is just string... Any comments?
regards,
George
|
|
|
|
|
1. No. ProgId simplifies the coclass instantiation. It's easier to remember ProgId "Excel.Applicatio" instead of it's equivalent UUID
2. Yes. I believe this link What is a ProgID and How Do I Change It?[^] might be helpful, if not, let me know.
PS: There are two term ProgId and VersionIndependetProgId
Cheers,
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thanks Sohail! You are progid Guru!
Two more comments,
1.
I read the two links below. My question is they are dealing with how to deal with typelib, but I have not found explicit samples about how to extract progid from typelib from them. Do you have any samples?
http://msdn.microsoft.com/en-us/library/ms221172.aspx[^]
http://msdn.microsoft.com/en-us/library/ms687303(VS.85).aspx[^]
2.
The article you recommended above handles quite well about version issues, but my issue is not dealing with version of the same component -- but different components have the same progid name accidently, suppose I develop a component and name it monitor (progid), but I found there is already a component named monitor (progid), what should I do to solve this issue in an elegant way?
regards,
George
|
|
|
|
|
1. Sorry, no specific sample as of now See if this help -
Writing a simple Typelibrary browser [^]
Reading The Type-Library[^]
2. There are few rules about naming ProgIds (see <progid> Key[^])
The format of < progid > is < program >.< component >.< version > without spaces and < and >
It is possible that two different components may use same ProgId. But since the ProgId is constructed using three different entities, the chances of collision can be reduced. The choice of ProgId should be made keeping in mind that ProgId's may not be unique unlike GUIDs.
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thanks Sohail,
I am very satisfied with your answer item 2 and I will try my best to follow the rules. But for item 1, if for client (COM consumer) either VB or C++, if they do not read progid from typelib, how could they know progid? Which API could let us retrieve progid for a coclass type and then we could use the retrieved progid to retrieve CLSID later.
regards,
George
|
|
|
|
|
When you author a COM Server for providing some service, your job is also to ensure that it can be easily consumed. For this, we provide TLB, interface headers etc. You must at least publish either CLSID or ProgId as part of your public header files or documentation. For example - if your component would be consumed by Scripting languages as well as C++ clients then you may publish ProgId (VBScript would use this) and CLSID(C++ client would use this, although using ProgId they can query CLSIDs). On the other hand, if you expect only C++ clients to consume your component service then providing CLSIDs only should suffice.
As mentioned in MSDN documentation - "You can use a ProgID in programming situations where it is not possible to use a CLSID. "
Let me know if this solves your query
PS: By "You", I mean the author of component.
Sohail
modified on Friday, September 5, 2008 6:20 AM
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thanks Sohail,
I think all of my questions are answered. Cool!
regards,
George
|
|
|
|
|
Glad I could help
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Hi Sohail,
I have another questions, which I have not found answer for a long time. I saw you are a COM Guru here. Not sure you know the answer.
The question is, then we use __uuid of macro to convert from Coclass name or interface name in IDL to GUID, why we have a prefix attribute __declspec?
For example, __declspec(uuidof("SomeCoClassName")?
regards,
George
|
|
|
|
|
I am no COM Guru. There are many Guru's who have published in depth articles on COM on CP
Well __declspec is used to apply Microsoft specific extended attributes, one of them being uuid which attached a GUID to a class. For example - novtable is one such attribute which when attached to a class will stop the compiler from generating a vtable.
For more details see the following link -
__declspec[^]
uuid[^]
__uuidof[^]
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thanks Sohail,
I like your style of providing many links.
My confusion is, in the MSDN page of uuid, what means "attaches a GUID to a class or structure declared or defined (full COM object definitions only) with the uuid attribute.".
The input for uuid is a string format of CLSID, the output is what? The most confusion is what means "attaches".
regards,
George
|
|
|
|
|
hi i have a code which was supposed to read data from serial com (bluetooth) and save in a file.
but when i send a audio file from my mobile to pc the program will not read the port i have
configured the bluetooth connection for serial communication (i.e from system stray selecting bluetooth icon and from quick connect selecting serial connection). instead it shows that connection is succesfull for PIM transfer, so do i need to write a application in my mobile to send data serially.. if u have any details about it please post me.. (right now i dont have any application in mobile iam directly sending file via bluetooth)...
|
|
|
|
|
Are you sure your mobile supports the Bluetooth Serial Port Profile?
Try to use Hyperterminal, or similar, to open a serial connection to the mobile and read data. When you get that working you can worry about your code on the PC side.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
hi the at command works correctly it echos ok.
this is my read data code
<br />
bool ReadPort()<br />
{<br />
long int dwSize = 0;<br />
bool hResult = false;<br />
std::string sb = "";<br />
DWORD dwEventMask;<br />
<br />
if(!SetCommMask(hComm, EV_RXCHAR)) <br />
{ <br />
return hResult;<br />
}<br />
<br />
if(WaitCommEvent(hComm, &dwEventMask, NULL)) <br />
{<br />
char szBuf[1024];<br />
DWORD dwIncommingReadSize;<br />
<br />
do<br />
{<br />
if(ReadFile(hComm, &szBuf, 1024, &dwIncommingReadSize, NULL) != 0)<br />
{<br />
if(dwIncommingReadSize > 0)<br />
{<br />
dwSize += dwIncommingReadSize;<br />
sb.append(szBuf);<br />
}<br />
hResult = true;<br />
}<br />
<br />
else<br />
{<br />
unsigned long error = ::GetLastError();<br />
hResult = false;<br />
printf("the error while reading error is %dl\n", error);<br />
break;<br />
}<br />
} while(dwIncommingReadSize > 0);<br />
<br />
*readData = new char[dwSize];<br />
strcpy(*readData, sb.c_str());<br />
return hResult;<br />
}<br />
else<br />
{<br />
return hResult;<br />
}<br />
<br />
}<br />
it stops to WaitCommEvent function i feel i need to do some settings for my phone and pc to transfer the data serially but now it is PIM iam totally blank if u have any such settings for the transfer of data via serial com of bluetooth plz send in me... my phone is nokia 6288 i know this is not the forum for phone settings but please help me...
|
|
|
|
|
When using the "Bluetooth Serial Port Profile" there are three main issues to overcome:
1. Setting up the Bluetooth connection to make it behave like a serial device and
2. Setting up the serial device
3. Read and write from/to the port
When you say you have tried to open the serial device, but it presents itself as "PIM" instead of a serial device, you probably have a problem with the first issue above. To verify this you can try using the Hyperterminal to send and receive the exact same data with the same port settings as you're trying to do in your code.
If that test succeeds you can start worrying about your code.
Regarding programming for serial communication I have done it quite a lot, but I've never used ::SetCommMask() or ::WaitCommEvent() .
I use overlapped mode and I have one worker thread that reads data and another worker thread that sends data. The data to be sent is put in a queue from which the sending thread reads it and calls ::WriteFile() . A semaphore that the sending thread is waiting on with ::WaitForMultipleObjects() is released when a new block of data is added to the send queue.
The reading thread issues a read request with a call to ::ReadFile() . Since overlapped mode is used the call will return immediately and the reading thread can wait on the event in the OVERLAPPED struct that will get signalled when data arrives on the port. The read data will be put in a queue and a user defined windows message gets posted to the main thread in order to inform it about the newly received data so it can take proper action.
Of course the queues are protected with critical sections.
Joseph Newcomer has written a good article about serial port programming here[^].
He uses a slightly different approach than I've described above, but the mind set is very much the same.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hello everyone,
String of STL does not contain trim/toupper/tolower, currently I always implement them manually. For trim, I use find first/last not of space technique, and for toupper/tolower, I always change them manually by adding some value to 'a' to form 'A' or vice versa.
My question is I want to find some best practices to implement them (one reason is I think my private implementation may be error prone and the other reason is I am not sure whether there is existing APIs which could be utilized) and comment about my current implementation issues.
thanks in advance,
George
|
|
|
|
|
George_George wrote: For trim, I use find first/last not of space technique, and for toupper/tolower, I always change them manually by adding some value to 'a' to form 'A' or vice versa.
My question is I want to find some best practices to implement them (one reason is I think my private implementation may be error prone and the other reason is I am not sure whether there is existing APIs which could be utilized) and comment about my current implementation issues.
For tolower and toupper use std::transform .
std::string Str = "nibu babu thomas";
std::transform( Str.begin(), Str.end(), Str.begin(), toupper );
std::cout << Str;
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Thanks Nibu!
How about trim? No built-in APIs?
regards,
George
|
|
|
|