stuck with what looks like a compiler bug in VS.NET 2003 vs VS.NET 2002
This is going to be a little vague I'm afraid as it's hard for me to provide
explicit details without a vast quantity of extra information.
I've recently changed compiler from .NET 2002 to .NET 2003. I have a fairly
complicated application, which is an ISAPI extension that relies on several
other rather large projects (Xalan, Xerces, ICU, boost). At some point, i'm
at the bottom of a pretty deep call stack, and I throw an exception which
travels up a lot of it.
It seems that in one particular module, a couple of the functions don't
manage to unwind the call stack properly -- it always crashes in either of
these two functions during the unwind sequence. It's 100% reproducible with
.NET 2003 and 100% not reproducible with .NET 2002, and depending on how
I've been tinkering with the code, always crashes in the same place. I've
tried sprinkling some extra try () { } catch (...) { throw; } blocks around
various parts of these functions. The result is that I can make the problem
go away, presumably by generating different unwind code. Oh, and this only
happens with a release build.
Normally I'd claim responsibility for mashing memory rather than pointing at
the compiler, but in the case, the application (and those things that it
relies on) have been proved to be very stable. I can also make this happen
with a wide variety of initial conditions (effectively doing things that
would drastically change the pattern of memory allocations up to that
point), pageheap /full doesn't spot anything, and if I _don't_ throw the
exception, then things all work as expected, even to the point of being able
to conduct stress tests that previously passed.
I realise that this is a bit of a long shot, but if anyone could offer any
advice on what to try or look for to be certain as to what is going on that
would be great. The application is open source, so if anyone has a great
deal of spare time then it should be possible to recreate it locally.
I'm out of ideas other than reading the compiler generated assembly at the
moment (which isn't an easy task as my asm is a bit rusty these days). If
it comes to it, I guess I'll have to drop back a compiler version, which
would be a pity.
Thanks,
Mark Tag: accessing the environment variables. Tag: 228791
is STL in msvc 6.0 (sp5) thread safe
Hi there!
We have app server written in C++ (stl is used a lot). And we use Visual
C++ 6.0 compliler to built it. App is not stable when it is heavy loaded. It
eather crashes or some static data in it becomes corrupted (so server stops
doing his duties).
We put some stuff from server into a test and with a lot of threads doing
subset of usual servers work. And test crashes within minute or so.
40 threads are intensively doing allocation, populating and freeing
containers such as std::map and std::set. Threads write only to their own
(private) containers and there are some shared containers that are only read
(via find method).
So the question is: are stl containers such as std::map and std::set in
VC6.0 thread safe in mentioned manner? And if they ar not - where to find
the fix?
--- With best wishes, Kirill.
* ...chasing dreams... Tag: accessing the environment variables. Tag: 228788
#pragma once
Hi,
Just out of curiosity, is using
#pragma once
equivalent to using
#ifndef HEADER_H
#define HEADER_H
...
#endif
?
Thanks,
Nelson Tag: accessing the environment variables. Tag: 228784
loading bitmaps from files
Hello all,
I'm writing a programme which needs to load bitmap files (*.bmp) from
disk and then access the raw pixel data. I'd like an easy way to get
that raw data as one plane, 32 bits per pixel.
Right now I'm using LoadImage() to get the file and then two calls to
GetDIBits(). The first call is to get the BITMAPINFO structure data so I
know how big a buffer to allocate for the pixel data, and the second
call actually gets the raw data.
hbmp = (HBITMAP)::LoadImage(NULL, lpszFile, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE);
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
rc = ::GetDIBits(::GetDC(NULL), hbmp, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
m_pclrBits = (COLORREF *)calloc(bmi.bmiHeader.biWidth *
bmi.bmiHeader.biHeight, sizeof(COLORREF));
rc = ::GetDIBits(::GetDC(NULL), hbmp, 0, bmi.bmiHeader.biHeight,
m_pclrBits, &bmi, DIB_RGB_COLORS);
Currently my programme just assumes that the raw pixel data will always
be 32bpp with only one plane, but I just don't know if that is the case.
::GetDC(NULL) returns the root (desktop) window, which on my computer is
32bpp, but it might not be on a different machine and for all I know
GetDIBits() might "translate" the raw data into however many bits/pixel
and planes the root window is using.
Would I be better off using ::GetBitmapBits even though the MSDN library
says that is an obsolute function?
Is there a way to ensure that the raw data is _always_ 32bpp and in a
single plane? I'd rather not have to write code to take number of colour
planes, bits per pixel and the colour table and translate "by hand" the
raw data into 32bpp. Too many variations/combinations, too much wasting
time. :-P
I'd prefer to write all the code myself, rather than downloading some
third-part toolkit which woud probably have more function than I need.
Thanks in advance.
P.s. Is there no function to write bitmap data to a *.bmp file? I found
the basic structure of a *.bmp file in the MSDN library help files, so
if I had to I could hack up a *.bmp file writer, but I'd rather not. Is
there a SaveImage() companion to LoadImage() that I could just pass an
HBITMAP handle to?
--
Cory Albrecht
http://cory.doesntexist.com/
"Star Trekkin' across the universe!
Always going forward 'cause we can't find reverse!" Tag: accessing the environment variables. Tag: 228777
unresolved external symbol __endthreadex and unresolved external symbol __beginthreadex
I just don't get it. I punch in the code JUST as it is written and it =
doesn't work:
//***************************
//
// Hello.h
//
//***************************
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};
class CMainWindow : public CFrameWnd
{
public:
CMainWindow();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
//**************************
//
// hello.cpp
//
//**************************
#include <afxwin.h>
#include "hello.h"
CMyApp myApp;
////////////////////////////
// CMyApp member functions
BOOL CMyApp::InitInstance()
{
m_pMainWnd =3D new CMainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
////////////////////////////
// CMainWindow message map and member functions
BEGIN_MESSAGE_MAP(CMainWindow, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CMainWindow::CMainWindow()
{
Create(NULL, "The Hello Application");
}
void CMainWindow::OnPaint()
{
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
dc.DrawText("Hello, MFC", -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
--------------------Configuration: hello95 - Win32 =
Debug--------------------
Compiling...
hello.cpp
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol =
__endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol =
__beginthreadex
Debug/hello95.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
The project was a Win32 Application. What have I done wrong? There is =
no indication that anything else is necessary but to me it looks like =
there are some includes not included or some libs not libed that should =
be included and\or libed.
--=20
George Hester
__________________________________ Tag: accessing the environment variables. Tag: 228775
VC SDK
I'm using VC 6 with latest Service pack (6).
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
I have been working with the above sample to display which OS the
program is running on. Prior to updating the SDK and SP the code above
worked flawlessly, Since updating, I get errors like
> c:\working\ostest\hello\hello.cpp(59) : error C2039: 'wProductType' : is not a member of '_OSVERSIONINFOEXA'
> c:\working\ostest\hello\hello.cpp(63) : error C2039: 'wSuiteMask' : is not a member of '_OSVERSIONINFOEXA'
> c:\working\ostest\hello\hello.cpp(63) : error C2065: 'VER_SUITE_PERSONAL' : undeclared identifier
According to MSDN these items are declared in Winbase.h. My include file
for Winbase.h does not have these declarations. Has there been
a change to this include file that your online sample does not address?
I have even uninstalled everything and reinstalled, applying the Service
Pack and Updating the SDK's.
Is there an update that I missed?
--
Regards,
Steve Topilnycky
Top Cat Computing
http://www.topcatcomputing.com/ Tag: accessing the environment variables. Tag: 228769
Writing a C++ program to send an email
Does anyone know of any API or COM object that allows you to send and email from a C++ program Tag: accessing the environment variables. Tag: 228768
max speed compilation failed
I have a simpe win32 dll.
when I make an optimization/max speed compilation, it always says:
Compiling...
Command line error D2016 : '/ZI' and '/O2' command-line options are
incompatible
if I use other options in optimization, it can compile.
I wonder if I remove /ZI /O2, is it still in max speed ?
or how can I get a max speed compilation ?
thanks.
/* Call Library source file */
#include "extcode.h"
#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include <winbase.h>
void GetSeeThrough(unsigned char *aLine,int *seeThrough,int aLMax,int aLMin)
{
register i,j,k;
for( j=0;j<256;j++)
{
//-----------added--below---------
if(j<=aLMin)
{
seeThrough[j]=150;//srcImage->Width;
}
else if(j>=aLMax)
{
seeThrough[j]=0;
}
else
{
k=0;
for(i=0;i<150;i++)//srcImage->Width
{
if(j<=aLine[i])k++;
}
seeThrough[j]=k;
}
}
}
_declspec(dllexport) void Go(long count, long *time);
_declspec(dllexport) void Go(long count, long *time)
{
int seeThrough[256];
unsigned char aLine[150];
int i;
int tt1,tt2,tt3;
*time=count*4;
tt1=GetTickCount();
for(i=0;i<150;i++)
{
aLine[i]=i;
}
for(i=0;i<count;i++)
{
GetSeeThrough(aLine,seeThrough,255,0);
}
tt2=GetTickCount();
tt3=tt2-tt1; //milliseconds
*time=tt3;
} Tag: accessing the environment variables. Tag: 228760
Sharing data between apps
Greetings, I know this has come up before, but I never needed
to know the details. Well now I do.
How do it use the CreateFile() API to create a memory-only
data block that I can use to share data between two or more
applications? If someone could point me to a good reference
that would be great.
Thanks
Murrgon Tag: accessing the environment variables. Tag: 228759
typedef struct question
i asked this before and forgot the answer:
i am doing this:
typedef struct
{
}MYSTRUCT
and inside the struct i want to declare a pointer to a MYSTRUCT .... but the
compiler doesn't like it, what do i need to do before hand again?
thanks Tag: accessing the environment variables. Tag: 228758
CopyFile() very slow
What is the best method (read fastest) of copying a file
I'm using CopyFile() but it is extremely slow. Below i
a small console app that illustrates this. Just replac
the hardcoded file paths with the path to a file ~10MB
Compile and run the program and see the reported times
Then go to Windows Explorer and copy the same file
My results were about 7 secs using CopyFile() an
instantaneous through Explorer
#include <windows.h
#include <stdio.h
#include <string.h
#include <time.h
#include <conio.h
int main(int argc, char* argv[]
char ampm[] = "AM"
time_t ltime
struct tm *today
time( <ime )
today = localtime( <ime )
if( today->tm_hour > 12
strcpy( ampm, "PM" )
today->tm_hour -= 12
if( today->tm_hour == 0 ) /* Adjust if midnight hour. *
today->tm_hour = 12
printf( "Begin time:\t\t\t\t%.8s %s\n"
asctime( today ) + 11, ampm )
CopyFile("c:\\temp\\big_file.zip", "c:\\temp\\big_file2.zip", 0)
time( <ime )
today = localtime( <ime )
printf( "End time:\t\t\t\t%.8s %s\n"
asctime( today ) + 11, ampm )
int ch
printf("\n\tPress any key to exit...\n")
ch = getch()
return 0
Thanks
Drew Tag: accessing the environment variables. Tag: 228755
Determining System Boot/Login Time
Is there a reasonably simple way to determine the date and time at which
the system booted and/or when the current user logged in? Tag: accessing the environment variables. Tag: 228749
Extracting data from a VARIANT in C/C++
I am writing an add-in for an application. The add-in is a DLL written in
C++. The parent application passes various parameters to a function in the
DLL. On of these function parameters is type "_variant_t". I need to
extract the string value from this _variant_t.
I'm an old C programmer from way back, but I'm not much of a C++ programmer,
so I am, as yet, unable to deduce the means fo doing this from the header
files.
Is there an MFC or Win32 library or class that provides the means of
extracting specific data types from a _variant_t?
Thanks in advance for any help.
Steve Tag: accessing the environment variables. Tag: 228742
WS_SYSMENU without CLOSE BOX
Hi there,
I'm trying to create a new window which only has a Minimize Box and Maximize
Box. I need to put WS_SYSMENU to show the Min and Max box, but the Close
Box also shows up. Is there any way to create a window with just a min and
max box without CLOSE box?
Thanks,
Robert Tag: accessing the environment variables. Tag: 228741
New[] and delete
Hi,
A Quick Question please ....
If I use new[1] can I use delete, instead of delete[] ?
I mean when I use, " Type_AddrObj lpAddress = new Type_AddrObj [1] ;"
Then which is correct ?
a) delete[] lpAddress ;
b) delete lpAddress ;
Since the size of array is always specified as 1.
Thanks.
Vipul Pathak ; Tag: accessing the environment variables. Tag: 228735
Disabled CTreeControl question
Hello!
If I select an item in a tree - and disable the whole tree - all the items
in that tree is "grayed".
How can I avoid that?
This is how I would like things to work - only one item should be grayed -
and I should not be able to click on this tree.
--
- Lars Tag: accessing the environment variables. Tag: 228733
Compilation error with std list class
Hi All,
When I try to include the header for a class that has a member
list<int> m_list;
I get over 100 errors of the nature:
"c:\program files\microsoft visual studio\vc98\include\functional(16) :
error C2143: syntax error : missing '{' before '<'"
Here is the complete header which I have cut down to the minimum in order to
show the error:
#include <list>
using namespace std;
class CMyContainer
{
public:
CMyContainer();
int GetSize();
private:
list<int> m_list;
};
Any ideas what is wrong?
Cheers,
Rob Tag: accessing the environment variables. Tag: 228721
How to send Email in VC Applications?
hi,
What is the best way to send Email in VC applications?
Thanks,
Behzad Tag: accessing the environment variables. Tag: 228718
Is it possible?
How to in VS 6 implement a library of a class so that the class can be used
in an application like,
main()
{
ClassFromLibrary o;
o.method();
...
}
Thanks! Tag: accessing the environment variables. Tag: 228717
Windows NT Screensaver
Hi
I've been tasked to create a screensaver that blanks the screen, and displays a customn dialog box when the use,r for want of a better word wiggles the mouse or uses the keyboard. However I'm not sure how to display the dialog box, if anyone could help it would be great. For reference I'm using vc++ 5.0 on Windows NT
Thank
Dave Tag: accessing the environment variables. Tag: 228716
Unknown bitmap format
Hi,
I want to update the toolbar, but it pops up "Unknown bitmap format",and I
can't change it at all.
How should I do?
Thanks in advance.
Cui Sheng Tag: accessing the environment variables. Tag: 228705
Error With Structures
I have the following code in VC6:
typedef struct SS1
{
int a;
int b;
int c;
} Struct1;
void Test()
{
const NUM_STRUCTS=1;
Struct1 *pS;
Struct1 *pA;
int ndx=0;
pA=(Struct1*)malloc(NUM_STRUCTS*sizeof(Struct1));
for(ndx=0;ndx<NUM_STRUCTS;ndx++)
{
pS=pA+(ndx*sizeof(Struct1));
pS->a=101;
pS->b=202;
pS->c=303;
} // end for
for(ndx=0;ndx<NUM_STRUCTS;ndx++)
{
pS=pA+(ndx*sizeof(Struct1));
cout<<"\n*"<<pS->a;
cout<<"\n*"<<pS->b;
cout<<"\n*"<<pS->c;
} // end for
free(pA);
} //
The code works fine if NUM_STRUCTS is 1, but causes an assert
error if NUM_STRUCTS is greater than one. I'm sure it is
something simple, but I can't figure it out. Thanks in advance.
--
Chip Pearson Tag: accessing the environment variables. Tag: 228701
Is the rand() known to be buggy? It repeat same value after 349 iterations!
I am issuing the srand(1) statement before every time I use rand() in a
for(;;) loop sequence.
Consistently, the value 4313, that showed up in iteration 340, repeat itself
in the 349th iteration !
If it would be a true random generator, and given that it is defined as
returning type int, it would use one of the (primitive) generating
polynomials of the 15th rank, such that it would guarantee not to repeat
even once before exhausting all values between 1 and 32767, while 0 is not
in the
game (different seeds should only impact the order in which these 32767
numbers
are generated (and possibly starting with different values)).
Anybody have a handy true random generator source code?
Thanks Tag: accessing the environment variables. Tag: 228698
URLOpenBlockingStream can't get new data from url until closing application
aloha
i am using the function URLOpenBlockingStream(...) to get some data
from a url and then parsing the data.
the problem is that after retrieving the data for the first time, the
next time i am trying to pull the data again the data is the same old
data from each url and i cant get a new data from the url until i am
opening the browser and refresh it or closing and opening the
application
my code is
CString getCurrentVal(CString tasUrl)
{
::CoInitialize(0);
CComPtr<IStream> pStream ;
HRESULT hr = ::URLOpenBlockingStream ( NULL,_T(tasUrl),&pStream,0,NULL
);
if (SUCCEEDED(hr) && pStream)
{
CString html;
while(SUCCEEDED(pStream->Read(buffer, size, &bRead)) && bRead > 0){
html += CString(buffer, bRead);
...
}
::CoUninitialize( );
}
is anyone have any clew ? Tag: accessing the environment variables. Tag: 228697
interrupt handling ...
I'm looking for a simple example of how to implement and interrupt
handler and a call to a function in my code.
I'm using Winme and VStudio 6 ...
I guess it problably different for other OS (as usually with Windoze)
it's not portable ...
Thanks in advance :-) Tag: accessing the environment variables. Tag: 228696
Iterating through an enum???
Is there anyway to iterate through an enumeration??
FOr example for an enum defined below
typedef enum
TST1 = 1
TST2 = 10
END_TST = 100
} TST_TYPE
If there anyway to do something lik
for ( TST_TYPES i; i != END_ST; i++
TST_TYPE tst = TST_TYPES[i]
or something similiar?
I basically have an enum that I need to build another list from. Thanks
-C Tag: accessing the environment variables. Tag: 228692
Dealing with folder name with spaces inside
Hi, there
When encountering folder name with spaces inside, such as C:\Documents and Settings, my system() program will return error. I am using CString strT.Format(_T("%s %s %s"), pszCmd, pszInput, pszOutput), then using system(strT) do the job. I thought it could be solved by adding "" arround those directories. Then I used
strT.Format(_T("\"%s\" \"%s\" \"%s\""), pszCmd, pszInput, pszOutput)
But it still failed. When I using those strings in Command Prompt, such as "pszCmd" "pszInput" "pszOutput", they works well. So what is the problem, and how to solve it
Thanks lot
Gary Tag: accessing the environment variables. Tag: 228687
Debug DLL files will only work on one computer
Hi,
Can anyone tell me why my Debug DLL files will only work on one
computer?
It seems like i can get it to work on another computer immediately
after a recompile, but if i commit it to my CVS server for a while,
and someone else downloads the DLL file on another computer, they are
unable to use the DLL files. Is there some setting i am missing?
Thanks! Tag: accessing the environment variables. Tag: 228680
Problem with Local time to System time conversion
Hi,
Any help would be much appreciated, and here's my problem:
I've used the function SystemTimeToTzSpecificLocalTime() to convert a UTC
based time to a local time and everything works fine. However,when I try to
do the reverse, that is, from a local time back to a UTC time. The function
TzSpecificLocalTimeToSystemTime();
is not supported under windows 2000 (only supported on XP/server2003)
So I tried the function FileTimeToLocalFileTime() as a work-around but my
time is always off by one hour because of daylight saving.
Are there any easier alternatives besides making my own timezone conversion
routines? Or does it mean that I'll have to implement my own version of
TzSpecificLocalTimeToSytemTime() ?
Thanks in advance! Tag: accessing the environment variables. Tag: 228679
NT User Password Authentification
Hi
I'm developing an app and part of what I want it to do is check that a users password is valid, however I'm a bit new to this asspect so would be grateful if anyone could point me in the direction of win32 api call that can be used to check a users password, or if this doesn't any web resource that covers this topic
Thank
Rob Tag: accessing the environment variables. Tag: 228673
forced to old C
Hi all,
I am currently using a working sample of an app that I intend to use
as my foundation for something else. When I compile this sample
I obtain a clean compile. However, when I intend to integrate with code
that supposedly should be supported (as to define a variable
anywhere in a function), it does not let me it forces me to declare
the variable at the beginning of the function. I've tried to look at
the project settings to see what is that is configured, but I do not
see anything that forces this app to use traditional C syntax
(i.e. I checked the compiler switches). Can anybody there suggest
what can be happening?
Thanks,
Carlos. Tag: accessing the environment variables. Tag: 228670
install modem from code
Please give any direction how can I install modem with INF files from code
VC++?
I tried
ShellExecute .... "rundll32.exe", "setupapi.dll,InstallHinfSection
DefaultInstall 132 " + sFullPath INI file
And I have no result.
regards, Sly Tag: accessing the environment variables. Tag: 228663
convert character
Hi,
I hope the question is not too off-topic...
Is there any function in VC7.1 or any SDK which...
1) ...converts a 8-bit char to the corresponding 16-bit unicode value, using
some given codepage?
2) ...does the reverse when possible?
for example, if I run charmap.exe I see "Euro sign", U+20AC (0x80) which is
exactly what I need.
--
The set of solutions is never empty.
Two solutions together form a new problem.
-- Mycroft Holmes Tag: accessing the environment variables. Tag: 228660
VC7.1 - put debug info in .exe not .pdb
In VC6, when building an debug .exe, the linker switch /pdb:none (combined with /debug and the /Z7 compile switch) put all the debug info into the .exe itself and no .pdb file was created
I believe I may have read somewhere that this is no longer possible in VC7.1 i.e. when building a debug exe I am forced to have the debug info in a .pdb file. I have certainly been unable to manage it so far, I always end up with my debug info in a .pdb file despite trying many different compiler/linker switch combinations. Is it true that VC7.1 no longer supports this ? If not, what are the magic words in order get the debug info into the exe and not create a .pdb file
Thank
Andy Tag: accessing the environment variables. Tag: 228658
what's the meaning of "car","cdr","cons" in tree's algorithm?
Hi!
I find a section of source code about binary tree's algorithm£¬I find the
struct:
typedef struct _BIN {
void *car; /* address of <car> */
void *cdr; /* address of <cdr> */
} BIN;
typedef struct _CELL {
int tag; /* tag of <cell> */
/* 0: cons */
/* 1: atom */
union {
BIN cons;
U_CHAR *atom;
} value;
} CELL;
there is "/* address of <car> */" & "/* address of <cdr> */" , but I don't
know what's the meanning of "car" , "cdr" & "cons"?
Thanks in advance! Tag: accessing the environment variables. Tag: 228654
GlobalFree throws exception after CPrintDialog::DoModal()
Hi!
I'm initializing a CPrintDialog to display a previously selected printer.
For this I allocate memory on the heap with GlobalAllo for the
CPrintDialog::m_pd.hDevNames (and m_pd.hDevMode (same problem)).
To the best of my knowlege I should use GlobalFree to clean up but after the
call to CPrintDialog::DoModal()
the memory i create with GlobalAlloc seems to get displaced or is
deallocated.
In debug mode a user breakpoint is called and I get a message saying:
Invalid Address specified to RtlFreeHeap
For now I have commented out calls to GlobalFree to make it work but i
suppose this gives me a memory leak.
Can anyone help out?
/ thanks in advance
Anders
Here's the code:
// allocate a new DEVNAMES object on global heap
int nSize = sizeDevNames + sizeName + sizeSpool + sizePort;
HANDLE local_hDevNames = ::GlobalAlloc(GPTR, nSize) ; // allocate on heap
LPDEVNAMES lpDevNames = (LPDEVNAMES)::GlobalLock(local_hDevNames); // lock
it
memset(lpDevNames, 0, nSize) ; // init to 0
// add the 3 strings to the end of the structure
...
::GlobalUnlock(local_hDevNames) ; // unlock
CPrintDialog nDlg(true);
nDlg.m_pd.hDevNames= lpDevNames;
if(nDlg.DoModal() == IDOK)
{ ... }
::GlobalFree(local_hDevMode); // here's the error Tag: accessing the environment variables. Tag: 228653
Why can't display the title of a Dialog?
With the dialog's property,I have checked its Style to TitleBar,Minimize
box,and its caption have some characters put into.
But when I run the application,I cannot find the title of the Dialog .
Why and how?
Thanks. Tag: accessing the environment variables. Tag: 228651
Is there a way to recall a constructor function of an already existing class object?
Given the following class A and object instantiation Ai:
class A {
int d;
public:
A(int a=0) {d=a;};
};
A Ai;
In order to reset Ai's data members, I thought simply to issue the following
statement:
Ai.A();
like calling any other public function member of A. But the compiler doesn't
like it.
Any elegant solution to accomplish it?
In reality, my A's data members are many and its quite complicated, that is
why I would like to reuse the constructor.
Thanks Tag: accessing the environment variables. Tag: 228640
Gethostbyaddr() problem...
Hi
I get 11004 error code in my program calling gethostbyaddr()
The simple code is as follows
-----------------------------------
struct hostent *hp
..
unsigned int addr;
addr = inet_addr(server_name)
hp = gethostbyaddr((char *)&addr, 4, AF_INET)
..
throw Exception( CWsaerr(), WSAGetLastError(), ...)
------------------------------------------------------
'server_name' is passed in as Ipv4 format, i.e. xxx.xxx.xxx.xxx (eg. 123.45.65.23
The error code has description of " Valid name, no data record of requested type."
Both the client and server systems are in the same network ..
What is the problem here
Thanks
Pete Tag: accessing the environment variables. Tag: 228639
C++ ray tracing for windows
Does anyone know of a c++ class library for ray tracing on winxp
regards,
Kurt Tag: accessing the environment variables. Tag: 228638
cursors in a dll
Is there a way to put a cursor resources in a dll and load them from either
within the dll or from the application that loads the dll? I am using
GetProcAddress to access functions within the dll.
Dave Tag: accessing the environment variables. Tag: 228633
Obtain PID's
I would like to know how to obtain a processe's owner from its pid
The sequence of
OpenProcess
OpenProcessToken
GetTokenInformation
LookupAccountSid
does not work on system processes.
This has been documented in MSDN as being casued by lack of
SE_DEBUG_NAME privelege. The KB article Q131065
describes how to enable this privelege in our process so that
OpenProcess does not fail on system processes
The said method works on all processes except system(pid 8) process
and CRSS process.
1)Why does this not work on these processes ?
2)Are there any other rights that have to be assigned to get this to work ?
3)Is there any other method that doesnt require these rights
to obtain the process owner name ?
Iam targeting NT 4.0 sp6 and above (2000 XP etc) Tag: accessing the environment variables. Tag: 228617
BUG? Access violation with ::swscanf, or it's just monday morning
I am using sscanf to scan a number, and as a guard I scan a character
afterwards and then check that the result of sscanf is 1 (i.e. that there is
no character after the decimal number). My format specifier is thus "%ld%c".
Using the wide version, access violation.
This is with VC6, not sure the SP level.
Here an entire program (except headers) that repeats the problem:
int main(int, char*)
{
long num;
char ch;
wchar_t wch;
wchar_t buf[] = "1p";
::sscanf("1p", "%ld%c", &num, &ch); // Works, num=1, ch=112 ('p')
::swscanf(buf, L"%ld%c", &l, &w_ch); // Works, num=1, w_ch=112 ('p')
::swscanf(L"1p", L"%ld%c", &num, &w_ch); // Access violation
return 0;
}
The stack trace is:
ungetwc(L'p', _iobuf *0x0012feec) line 184 + 33 bytes
_un_inc(L'p', _iobuf *0x0012feec) line 1068 + 14 bytes
_winput(_iobuf *0x0012feec, const unsigned short *0x00428040,
char*0x0012ff20) line 719 + 26 bytes
swscanf(const unsigned short * 0x00428074 `string', const unsigned short *
0x0042803c `string') line 74 + 17 bytes
main([omitted])
in main, &l = 0x0012ff7c here, and &w_ch = 0x0012ff74.
Memory
0x00428074 = "1.p.k.j."...
0x0012feec = 0x76 0x80 0x42 0x00 (i.e. 0x00428076 which is pointer to the
"p" in the format string)
0x00428040 = "d.%.c.\0."
0x0012ff20 = 0x74 0xFF 0x12 0x00 (i.e. 0x0012ff74, &w_ch).
The instruction giving the AV is:
mov word ptr[edx], cx
where ECX=0x00000031 ('1') and EDX=0x00428074, i.e. the address of the start
of the buffer. ungetwc is attempting to write to the buffer, which is
presumably in read-only memory as it is a string literal.
So I conclude that swscanf, via ungetwc, is not respecting the constness of
the 'buffer' input parameter. This causes an AV if the buffer is in fact in
read-only memory.
In real applications, the buffers are unlikely to be in read-only memory,
but this bug does indicate that it is not threadsafe to use swscanf if the
buffer is shared between threads.
No similar behavior is exhibited by the narrow version, sscanf.
I do not need suggestions for workarounds. Tag: accessing the environment variables. Tag: 228613
Arguments to winmain
Hi There!. I am a newcommer in MFC programming.
How does one parse parameters passed as command line arguments in the Win32 environment? I know i can use lpCmdLine, but how do i do that? Can someone show me an example. By the way I am useing Embedded Visual c++ Tag: accessing the environment variables. Tag: 228610
"Yes to all" button in messagebox
Hello.
Is it possible display "yes to all" button in my messagebox with VC++ 6?
What is the flag that I need? In msdn I don't see anything about it.
What is the returning value in that case?
Thanks
Jordi Tag: accessing the environment variables. Tag: 228599
ShellExecute Link error error
I encountered a link error when compiling a code which contains ShellExecute
error LNK2001: unresolved external
symbol __imp__ShellExecuteA@2
Do I need to include special library
=============================================
This is the code: HSWShellExec.c
#include <windows.h
#include <shellapi.h
#include "ShellExec.h
int result
/*************************************************************************
JNIEXPORT jint JNICALL Java_ShellExec_execute(JNIEnv *e, jobject o,
jstring command
/*************************************************************************
const jbyte *cmd = (*e)->GetStringUTFChars( e, command, NULL )
HINSTANCE inst = ShellExecute( 0, "open", (const char *)cmd,
NULL, NULL, SW_SHOW )
(*e)->ReleaseStringUTFChars( e, command, cmd )
return( (UINT)inst > 32 )
============================
This is the command
cl -Ic:\j2sdk1.4.1_02\include -Ic:\j2sdk1.4.1_02\include\win32 -LD HSWShellExec.c -FeHSWShellExec.dl
=========================
This is the setting
set LIB=C:\Program Files\Microsoft SDK\Lib;C:\Program Files\Microsoft Visual Studio\VC98\lib;C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98
set INCLUDE=C:\Program Files\Microsoft Visual Studio\VC98\Include;c:\j2sdk1.4.1_02\include;c:\j2sdk1.4.1_02\include\win32
=====================================
This is the Link error
HSWShellExec.ob
Creating library HSWShellExec.lib and object HSWShellExec.ex
HSWShellExec.obj : error LNK2001: unresolved external
symbol __imp__ShellExecuteA@2
HSWShellExec.dll : fatal error LNK1120: 1 unresolved external Tag: accessing the environment variables. Tag: 228598
the behavior of vc7.1 exception
Hi, experts. i write a simple program to test EH in visual c++ 7.1:
void throwfunction()
{
throw "test";
}
class A
{
int i;
public:
A(int I):i(I){
cout<<"---------------------------A:"<< i <<"-----------------------\n";
}
~A()
{
cout<<"--------------------------~A:"<< i <<"-----------------------\n";
}
};
int main(int ,char*)
{
A b(1);
throwfunction();
cout << "---after throw--------------\n";
return 0;
}
According to TC++ 3rd(14.4.2),"resource acquisition is initialization". I
think the result should be :
-------------A:1---------------------
------------~A:1---------------------
But the runtime result is strange!
if it is debug version exe, when u run this program,will popup a dialog and
there are 3 choices:
1. abort: if u select this one, the result is:
-------------A:1---------------------
2. retry : if u select this one, the result is:
-------------A:1---------------------
------------~A:1---------------------
it is a expected result.
3. ignore:if u select this one, the result is:
-------------A:1---------------------
This application has requested the function to terminate it in an unusual
way. please.....
if it is a release version the result is similar with 3 above.
what is reason? and how can I get the expected result ?
In addition, i add try..catch.. in the main:
int main(int ,char*)
{
try
{
A b(1);
throwfunction();
cout << "---after throw--------------\n";
}
catch(...)
{
throw;
}
return 0;
}
the result is:
-------------A:1---------------------
------------~A:1---------------------
it is the expected result, but why? Tag: accessing the environment variables. Tag: 228596
virtual function and list
class Base
{
public:
virtual void virt();
...
};
class Derive1 : public Base;
class Derive2 : public Base;
main()
{
list<Base*> list1;
Derived1 d1;
Derived2 d2;
list1.push_back(&d1);
list1.push_back(&d2);
list1.begin()->virt();
...
list<Base&> list1;
Derived1 d1;
Derived2 d2;
list1.push_back(d1);
list1.push_back(d2);
list1.end().virt();
}
Is there anything wrong with the code?
Will list1.begin()->virt(); execute the virt() in Derived1?
Will list1.end()->virt(); execute the virt() in Derived2?
Thanks for your help! Tag: accessing the environment variables. Tag: 228594
CALLBACK FUNCTION of timeSetEvent()
The CALLBACK FUNCTION of timeSetEvent() is implemented by WINMM creating a
time critical priority thread on behalf of its client and executing in its
client's context.
Does this mean that the variables shared between the CALLBACK FUNCTION and
its client thread should be synchronized?
How to make all the execution of statements in the CALLBACK FUNCTION atomic?
In other words, how to avoid that CALLBACK FUNCTION changes some variables
but all, and then is interrupted by its client gets running with
"half-changed" variables?
Is it possible that CALLBACK FUNCTION can be preempted at all?
Thanks for your help! Tag: accessing the environment variables. Tag: 228592
Memory size limit for DDE APIs( like GlobalAddAtom() )
This question is about Windows API call, not vc. Sorry I don't know which group to post it
I got a strange result when use DDE to transfer data to Excel. What I'm doing is to read a file, and pu
data into Excel through DDE. The program will crash at different cell on different PCs (NT, XP, 2000). E.g.
on a NT, if I plan to transfer records that has 90 columns each, then my program crashed at record 18
(Excel stopped at R184C50). If I cut the column number by half (i.e., each record now has 45 columns), the
Excel stopped at R372_C8. This looks like that a global memory with limited size is somehow messed up
(184X90 almost = 372X45 )
We are using the DDE API calls directly. We use GlobalFindAtom() to check if an item is there; if not
call ClobalAddAtom() to add it. Trace shows that when we call GlobalFindAtom() to find item "R184C51"
the function returns a value saying this item is there when it's definitely not. When we call GlobalGetAtomName(
to retrieve this atom, sure it's not there (sometimes we do get some strings back, but the string looks lik
it's from a wrong memory address, something like "B_comple" ). To work around it, we tried to delete
such an Atom (in a WHILE loop), but it can't be done and the program went into a dead loop. We the
tried to change the form of the item from "R184C51" to "R184C051", "R0184C051",..., etc, and add the
new item; but this won't work either (sometimes works, some times not). So, the system memory is totall
messed up (each time we have to reboot to do another testing). BTW, the returned atom is always in the
correct range ( > 0xC000). Also, sometimes when we call GlobalFindAtom() to find say, R250C9, it ma
give us an atom value of say, R16C33, and of cource Excel cell R16C33 is wrongly updated
If the array of records is smaller than the crash threshod (e.g, less than 184 records when we're tryin
the 184X90 data), there's no problem at all. All the values can be correctly transfered to Excel. So, the
question is, is there a limit for the number of atoms that can be added into the global atom table by
calling GlobalAddAtom() ? Note that the call didn't give us any error indication, and as I said, our proble
begins when GlobalFindAtom() says it find a atom, when such an atom is not there at all
Thanks for help Tag: accessing the environment variables. Tag: 226591
How to access the environment variables in VC++ 6.0 console application ? Can anybody of you please give me an example
for the same ?
"Bansidhar" <anonymous@discussions.microsoft.com> wrote in message
news:8741C535-1900-4C34-A2B6-FACAD91A2169@microsoft.com...
> How to access the environment variables in VC++ 6.0 console application ?
Can anybody of you please give me an example
> for the same ?
If you have the MSDN documentation see the "getenv" / "_wgetenv" function.
It returns a char*
/* Get the value of the LIB environment variable. */
char *libvar;
libvar = getenv( "LIB" );
> How to access the environment variables in VC++ 6.0 console application ?
Can anybody of you please give me an example
> for the same ?
>
Look up "getenv" in MSDN, sample code is included in the help.