|
Hi everyone,
I wasn't sure if this is a COM issue or MFC issue, so I also posted this question in the COM message board...
I have an MFC app (with a CWinApp-derived object) that uses COM objects (Crystal Reports). The COM library is imported into my project via the #import directive. I'm using VStudio 6.0 sp5.
I've created a global object called _com_init:
struct ComInit {
ComInit() { ::CoInitialize(NULL); }
~ComInit() { ::CoUninitialize(); }
} _com_init_;
This way, I guarantee that COM will initialize before the _main() and terminate after the _main().
When my program reaches ~ComInit() and calls ::CoUninitialize(), I see the following message in my Debug Output Window:
First-chance exception in MyApp.exe (OLE32.DLL): 0xC0000005: Access Violation.
Any ideas? I've looked up other CoUninitialize threads in these forums, but couldn't figure out something that would solve my problem...
Thanks.
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
The most important aspect of using COM with MFC is to initialize and uninitialize COM correctly.
Instead of using a global object, I suggest that you put ::CoInitialize(NULL) in the start of your CWinApp-derived application's 'InitInstance' and ::CoUninitialize() o the end of the same application's 'ExitInstance' (Before return call). This way, the initialization and uninitialization are handled smoothly.
As for the actual problem, I have just about no idea of where it lies. I suggest using the above methodology to utilize COM server.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I already tried that. It was a lot worse when I did that. The result was about a zillion "Access Violation" messages instead of just one. I think there was also a "Stack overflow" message somewhere among them...
Also, it may have been unclear earlier, but the program doesn't abort with an Access Violation MESSAGE BOX. I only see the message in the debug output window. If I try what you suggested, I also get an Access Violation message box...
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
Have you determined that the COM server is indeed initialized?
if(::CoInitialize()!=S_OK)
MessageBox(_T("COM INIT FAILED"),NULL,MB_ICONERROR);
??
|
|
|
|
|
Yes, I have. I get S_OK.
/=/=/=/=
Deus
/=/=/=/=
|
|
|
|
|
HI.
I am starting out on Winsock stuff. I have been lookin gat the articles. For using any Winsock type commands, I need the Platform SDK? Is there an way without the Platform SDK? I was looking at how to down load this, do I only need the CORE SDK?
Thanks.
|
|
|
|
|
For winsock stuff, you dont need anything other than what you get in VisualStudio.
|
|
|
|
|
Like johnny said - use what you get in VS.
Easiest and most preferred for beginners is to create a class derived from CAsyncSocket - and override SetParent function. I've tried other methods which are more in-depth, but still find this one the easiest and most straight-forward. Don't forget AfxSocketInit().
I did not write W32.Blaster quit asking.
|
|
|
|
|
I have the following code where I am readin the file. Each line ends by '~'. I was able to get the first line, but I could not get the 2,3... lines.Can't see where my error is
do
{ string line;
getline(f,line,'~');
if (f.eof()) break;
getline(f,dump);
cout << line << endl;
count++;
} while (true);
|
|
|
|
|
If the while loop is terminating (prematurely), the if (f.eof()) condition must be evaluating to TRUE. Can you confirm or deny?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hi im aswin,
i need help recording CSocket. i want to know the difference between csocket and CAsyncSocket and which is the best to use.
1) When i use CSocket if one application acts as a server and other as client if the client disconnect abruptly how do i know that.
2) How do i make sure client has received correct datat the server has sen.
3) how do i send file using CSocket which may be more then 1 MB.
4) how do i make sure that a port isnt used by any other application.
5) Consider i use create command with port 1102. but when i use getport method i see that it shows different port.
plz help me in this situation as this is my first day in a company after graduating this april.
Regards
Aswin.N.Paranji
India
|
|
|
|
|
1) I have never used CSocket, but I would suggest that CAsyncSocket provides what you need here and will be easier to use - just override the OnClose function, set the AsyncSelect flags, and you will be notified when the remote client disconnects.
2) You dont need to do anything. TCP/IP ensures that the data is correct.
3) Just send it, theres nothing special you need to do because its 1MB.
4) Try and open the port. If it fails look at the error code and see if it indicates the port is in use. If you want to know beforehand then you can try and connect to the port and expect a failure - a success means the port is open.
5) I cannot see a getport function within CSocket or CAsyncSocket - what are you using to obtain the information? If you create a socket on a port then, provided its not in use, thats the port that will be used.
|
|
|
|
|
sorry i use getpeername function within casyncsocket.
i would be happy if you can explain me what is blocking.
|
|
|
|
|
Hi:
In ClistCtrl,I want to change the icon of some item.And I try :
m_ctrlListDevice.SetItem(nItem,0,0,NULL,1,0,0,0);
but nothing happen.The icon isn't changed. Why? How could I do to change the icon?
Thanks
Benben
|
|
|
|
|
Shouldn't it be:
m_ctrlListDevice.SetItem(nItem, 0, LVIF_IMAGE, "", 1, 0, 0, 0); This assumes, of course, that m_ctrlListDevice.SetImageList() has been previously called and that at least two images exist in the list.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks.MSDN doesn't tell me this clearly.
Thanks
Benben
|
|
|
|
|
hi all,
whats the major difference between a Service and a Exe
|
|
|
|
|
Service is in fact an exe that is running under the Service Control Manager (SCM) context = do not need some user to start it interactivelly. It's called daemon at uni*es.
|
|
|
|
|
hi Everybody
my problem regarding insert section and key name in ini file using map.i have done all this by using vector
but i want to it compatible with map.i have used two structure given belowusing vector
// st_key
// This structure stores the definition of a key. A key is a named identifier
// that is associated with a value. It may or may not have a comment. All comments
// must PRECEDE the key on the line in the config file.
typedef struct st_key
{
t_Str szKey;
t_Str szValue;
t_Str szComment;
st_key()
{
szKey = t_Str("");
szValue = t_Str("");
szComment = t_Str("");
}
} t_Key;
typedef std::vector<t_key> KeyList;
typedef KeyList::iterator KeyItor;
// st_section
// This structure stores the definition of a section. A section contains any number
// of keys (see st_keys), and may or may not have a comment. Like keys, all
// comments must precede the section.
typedef struct st_section
{
t_Str szName;
t_Str szComment;
KeyList Keys;
st_section()
{
szName = t_Str("");
szComment = t_Str("");
Keys.clear();
}
} t_Section;
typedef std::vector<t_section> SectionList;
typedef SectionList::iterator SectionItor;
/// General Purpose Utility Functions ///////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
void Report(e_DebugLevel DebugLevel, char *fmt, ...);
t_Str GetNextWord(t_Str& CommandLine);
int CompareNoCase(t_Str str1, t_Str str2);
void Trim(t_Str& szStr);
int WriteLn(fstream& stream, char* fmt, ...);
fefgfgfgfgfg
|
|
|
|
|
Dear Friends ,
I am creating a toolband for IE and i need to change the text on the timer tick after a interval of 10 seconds.I tried doing it using
TBBUTTONINFO but it seems nothing is happening.Here is the code for that.
void CKBToolBarCtrl::OnTimer(UINT ID)
{
char str[10]="test";
LPSTR pszBuf=str;
TBBUTTONINFO tbi;
tbi.dwMask = TBIF_TEXT;
tbi.cbSize = sizeof (TBBUTTONINFO);
tbi.pszText = (unsigned short *)pszBuf;
tbi.cchText = sizeof (pokerstr);
CToolBarCtrl::SetButtonInfo(ID_BUTTON1, &tbi);
}
one more problem i am facing when i try to assign pszBuf to tbi.pszText without casting it gives me error unable to convert from char* to unsigned short* , however when i write the same code for simple MFC application everything works fine.
Any help will be heartly appreciated.
|
|
|
|
|
HI,
I have a MFC DLL project.This created DLL sits in the third party exe.
One of the statement in the DLL code:
************************************************************************************
STRING str = STRING(GetModuleHandle("X.dll"), 0x409, STR_PROGRAMD);
where
// MessageId: STR_PROGRAMD
// MessageText:
// UMDC_PROGRAMD%0
#define STR_PROGRAMD ((DWORD)0x00001006L) in msgtable.h file
************************************************************************************
but the the variable str is returning "FormatMessage() failed for 100001006"
Getlasterror() returns "1813- The specified resource type cannot be found in the image file"
Pls help what could be the problem??
Thnks in advance
|
|
|
|
|
At a guess, it looks like the code is trying to load a string resource from the string table of the DLL, but the string is not present. Try opening the DLL as resources in VC and check to see whether a string entry with tht ID number exists.
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
In addition to Roger's suggestion, look into the AFX_MANAGE_STATE() macro. By default, resource templates come from the main application. Since your resource is actually in the DLL, the module state needs to be changed to that of the DLL.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi Mr.Alexander !
I need to writing a Dial-Up Server project in Win98 by vc++.
I wrote a program by TAPI 2.0 that it's can do :
1) wait for call .
2) answer to call .
3) send and receive data .
But problem is here that I can not set over modems(client & server ) TCP/IP protocol (I can't set IP over modems that connecte together.)
If could help, please let me know.
A BIG thanks in advance.
|
|
|
|
|
Umm..
A modem usually connects to the serial port of your computer. It, by itself, does not use TCP/IP protocol, and doing that is impossible. After all, a serial port can only belong to a single computer.
So, you cannot use TCP/IP protocol over a modem connection unless you write respective software. This software would be responsible for checking if a modem connection is open (a serial connection), then it creates a virtual network interface and binds this interface to the serial connection. Now, each TCP/IP packet your computer sends is routed through the modem connection. You can consider it like a small LAN running over a phone line. The software is responsible for handling it.
I do not know if there are any software examples which are used to do dial-up networking connections. Windows already has a functioning support for this, so how about allowing it to do the job ? Just setup the computers to use dial-up networking and create a connection between the two computers. Then just use Windows Sockets to open a connection, assuming that the target computer is running a software that is listening to such connections from the "virtual network".
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|