|
Hi,
I have the following in my code:
#define SIZE 16384
while(buffer_len = fread(buffer, 1, SIZE, src))
It works fine till the SIZE doesn't exceed 16K, but when i use 131072 for SIZE's value fread returns 0 on the first call, and it isn't eof.
But while I debug it and use:
call fread(buffer, 1, 131072, src)
it returns 131072 and the buffer is OK.
May be I'm missing some compilations flag?
I'm using GNU gdb Red Hat Linux (6.3.0.0-1.143.el4rh) on Red Hat Enterprise Linux AS release 4 (Nahant Update 5)
Thanks.
|
|
|
|
|
Evgeni57 wrote: I'm using GNU gdb Red Hat Linux (6.3.0.0-1.143.el4rh) on Red Hat Enterprise Linux AS release 4 (Nahant
Why are you posting on the Visual C++ / MFC Forum then?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
fread returns the number of full items actually read, which may be less than count if an error occurs or if the end of the file is encountered before reaching count. Use the feof or ferror function to distinguish a read error from an end-of-file condition. If size or count is 0, fread returns 0 and the buffer contents are unchanged.
|
|
|
|
|
Hi all
I am new in vc++.I hava application which have one dailog box A.And now i am inserting a new dailog B.And i want to show out of A on B list Box .Plz help me
|
|
|
|
|
|
Hi all,
This is my thread below:
static DWORD WINAPI Thread_no_1( LPVOID lpParam )
{
static CUpdateServiceModule *p;
CSiteCode m_CSiteCode;
RMproduct* MPoint = new RMproduct(L"ManagePoint",ManagepointService, ManagepointVersion);
if (p->isPrdInstalled(MPoint))
{
p->GetVersion(MPoint);
MPoint->m_SiteCode = m_CSiteCode.GetMPSiteCode(MPoint->m_SerialNo.c_str());
p->m_pWebServiceSoap = new LSWebServiceSoap;
p->dloadAvailable = p->DoCheckForProductUpdates(MPoint);
if(p->dloadAvailable)
{
p->GetUpdate(MPoint);
}
}
delete MPoint;
delete p->m_pWebServiceSoap;
delete p;
return 0;
}
The bold part is crashing that is declared as private inside the class:
private :
//Webservice
LSWebServiceSoap *m_pWebServiceSoap;
I have tried putting it inside the constructor but it crashes there, what do you guys suggest? I also tried initializing a new instance of the class which causes crashing right away inside the thread so i just made a pointer then initialize the m_pWebServiceSoap however it still crashes when i make an instance of it.
Please help.
Thanks,
Jayjay
|
|
|
|
|
try it again after add the ::CoInitialize(NULL); before "p->m_pWebServiceSoap = new LSWebServiceSoap;"
【成功就是在跌倒之后还能爬起来...】
|
|
|
|
|
Hi McKay
This is what i did:
p->GetVersion(MPoint);
MPoint->m_SiteCode = m_CSiteCode.GetMPSiteCode(MPoint->m_SerialNo.c_str());
::CoInitialize(NULL);
p->m_pWebServiceSoap = new LSWebServiceSoap;
p->dloadAvailable = p->DoCheckForProductUpdates(MPoint);
if(p->dloadAvailable)
{
p->GetUpdate(MPoint);
It still crashes. Any other advise? should i instantiate a new p like
static CUpdateServiceModule *p = new CUpdateServiceModule; ?
Thanks,
Jayjay
|
|
|
|
|
Oh,I known, it crashes because the point "p" is not initalize,
(static CUpdateServiceModule *p;// = new CUpdateServiceModule;)
you should new the class before you user the "if (p->isPrdInstalled(MPoint))",
you should add the line "static CUpdateServiceModule *p = new CUpdateServiceModule; ".
try it again ,pls.
【成功就是在跌倒之后还能爬起来...】
You can run far. You can take your small precautions. But have you really gotten away? Can you ever escape? Or is the truth that you do not have the strength or cunning to hide from destiny. But the world is not small, you are. And fate can find you anywhere.
|
|
|
|
|
Hi Mckay,
Whenever I try making a new instance of the class i get this error:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
Program: ...
File: c:\program files\microsoft visual studio 8\vc\atlmfc\include\atlbase.h
Line: 2706
Expression: _pAtlModule == 0
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
at:
class ATL_NO_VTABLE CAtlModule : public _ATL_MODULE
{
public :
static GUID m_libid;
IGlobalInterfaceTable* m_pGIT;
CAtlModule() throw()
{
ATLASSERT(_pAtlModule == NULL);
Is there a way to counter this or solve this?
Thanks,
Jayjay
|
|
|
|
|
Hello,
This is with reference to an article at http://www.developer.com/net/cplus/article.php/3624581 about Programming the Windows Vista Event Log.
We build and run the application as per information found in this article. And getting the Operational and Debug events.
Thats great.
Now, we have made some changes and getting some wrong output.
I request you to have quick look on the following stuff and let us know where we are wrong.
We have made some changes in the code as follows –
The manifest.h file contains –
#pragma once
EXTERN_C __declspec(selectany) const GUID MYCOMPANY_HPFS_PUBLISHER = {0x9cde86c9, 0xdfb9, 0x463f, {0xb2, 0xc5,0x71,0xee,0xc2,0x32,0xa6,0x9c}};
#define MYCOMPANYOP 0x10
#define MYCOMPANYDEBUG 0x0
EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR DNP_OP_EVENT = {0x1, 0x0, 0x10, 0x4, 0x0, 0x0, 0x8000000000000000};
#define DNP_OP_EVENT_value 0x1
EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR DNP_DEBUG_EVENT = {0x2, 0x0, 0x0, 0x4, 0x0, 0x0, 0x4000000000000000};
#define DNP_DEBUG_EVENT_value 0x2
#define MSG_SimpleMessage 0xB0000001L
Here, we have just renamed #define values.
Also, we have made some changes in EventLogging.Cpp as follows –
// EventLogging.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <evntprov.h>
#include <winevt.h>
#include "Manifest\manifest.h"
# pragma comment (lib, "wevtapi.lib")
int _tmain(int argc, _TCHAR* argv[])
{
REGHANDLE hPub = NULL;
ULONG res = EventRegister(&MYCOMPANY_HPFS_PUBLISHER, NULL, NULL, &hPub);
if (ERROR_SUCCESS == res){
_tprintf(_T("Event registered successfully\n"));
}
else{
_tprintf(_T("Could not register event\n"));
}
EVENT_DATA_DESCRIPTOR opEventDesc;
PWSTR pwsOp = L"HPFS : My Operational Event";
EventDataDescCreate(&opEventDesc, pwsOp, ((ULONG)wcslen(pwsOp)+1)*sizeof(WCHAR));
res = EventWrite(hPub, &DNP_OP_EVENT, 1, &opEventDesc);
if (ERROR_SUCCESS == res){
_tprintf(_T("Operational event successfully raised\n"));
}
else{
_tprintf(_T("Could not raise operational event Error = %i\n"), res);
}
EVENT_DATA_DESCRIPTOR debugEventDesc;
PWSTR pwsDebug = L"HPFS : My Debug Event";
EventDataDescCreate(&debugEventDesc, pwsDebug, ((ULONG)wcslen(pwsDebug)+1)*sizeof(WCHAR));
res = EventWrite(hPub, &DNP_DEBUG_EVENT, 1, &debugEventDesc);
if (ERROR_SUCCESS == res){
_tprintf(_T("Debug event successfully raised\n"));
}
else{
_tprintf(_T("Could not raise debug event. Error = %i\n"), res);
}
EventUnregister(hPub);
return 0;
}
Also we have made some changes to manifest.xml file as follows –
<!--Publisher Info -->
<provider name="MYCOMPANY-HPFS"
guid="{9CDE86C9-DFB9-463f-B2C5-71EEC232A69C}"
symbol="MYCOMPANY-HPFS_PUBLISHER"
resourceFileName="C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe" messageFileName="C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe">
<!--Channel to which this Publisher can publish -->
<channels>
<channel chid="MyOpChannel"
name="MYCOMPANY-HPFS/Operational"
type="Operational"
symbol="MYCOMPANYOP"
isolation="Application" enabled="true"/>
<channel chid="MyDebugChannel"
name="MYCOMPANY-HPFS/Debug"
type="Debug"
symbol="MYCOMPANYDEBUG"
isolation="Application" enabled="true"/>
</channels>
Where "C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe" this is my .exe address.
Now, we are getting Debug events properly. But, we are not able to get Operational events. We can see “Operational” tab but no event added in that.
Actually, our intention is to create a tab structure in Event viewer “Applications and Services Logs > MYCOMPANY > HPFS > Operational” and read and write operational events.
Kindly let us know what is the problem in our code.
Thank you.
With regards,
Shashikant
|
|
|
|
|
I need load two DLL, a.dll and b.dll.
In a.dll has fun() function and b.dll has fun() too.
How to distinguish between a.dll/fun() and b.dll/fun().
|
|
|
|
|
|
hanlei0000000009 wrote: In a.dll has fun() function and b.dll has fun() too.
How to distinguish between a.dll/fun() and b.dll/fun().
Using GetProcAddress and a typedef (with different names) for prototyping the function should help.
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
|
|
|
|
|
I need to display icons in my TreeCtrl , icon image should change depending on the tree node type.
If it is Root node I need to display one icon. And for branches which is having child items I need to dispay different icon. For child items with no roots I need to display separate icon.
How do I know the nodes which are having child items ?
Presently iam able to show only one icon to all nodes.
m_lstImages.Create( 16, 16, ILC_COLOR, iconCount, 1 );
for( int i = 0; i < iconCount; i++ )
{
HICON hIcon;
hIcon = AfxGetApp()->LoadIcon( IDI_ICON1 + i );
m_lstImages.Add( hIcon );
}
GetTreeCtrl().SetImageList( &m_lstImages, TVSIL_NORMAL );
|
|
|
|
|
Preethi_123 wrote: How do I know the nodes which are having child items ?
Use CTreeCtrl::ItemHasChildren
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
|
|
|
|
|
Hi all,
This is my constructor:
CUpdateServiceModule::CUpdateServiceModule()
{
m_status.dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE;
m_bIsRunning = FALSE;
m_bIsPaused = FALSE;
MessageBox(NULL, L"Contructor",NULL, NULL);
}
I am wondering why the message box constructor appears when ever I rebuild my project, install the project and uninstall the project. Can anyone tell me why is that or what information do you guys need to know that?
Thanks,
jayjay
|
|
|
|
|
because the constructor function of CUpdateServiceModule() will be called by the com register.
【成功就是在跌倒之后还能爬起来...】
|
|
|
|
|
even during uninstall and building?
|
|
|
|
|
When building your project, VC will register the component at the end of the compilation, thus the message box is shown.
And I guess an instance of that class is created when the component is unregistered (during an uninstall).
|
|
|
|
|
|
register and unregserver message during uninstall and building.
【成功就是在跌倒之后还能爬起来...】
|
|
|
|
|
monsieur_jj wrote:
CUpdateServiceModule::CUpdateServiceModule()
{
m_status.dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE;
m_bIsRunning = FALSE;
m_bIsPaused = FALSE;
MessageBox(NULL, L"Contructor",NULL, NULL);
}
Be careful with the m_status.dwControlsAccepted .
The way the statement is written it will most likely contain garbage data when you build for release, unless it's initialized in some base class of CUpdateServiceModule .
Consider changing to
m_status.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE;
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I get similiar other warnings such as
warning C4996: 'strcat' was declared deprecated
warning C4996: 'fopen' was declared deprecated
warning C4996: 'itoa' was declared deprecated
why and when do these warnings arise ?
How to overcome them?
- thanks..
|
|
|
|
|
kapardhi wrote: why and when do these warnings arise ?
Because Microsoft introduced more secure versions of these functions. So either follow the advice given in the warning message (use the more secure version, like strcat_s) or disable the warning 4996 (you can specify that in the project options).
|
|
|
|
|