Tricky one.. window text spy problem
Hi !
I've encountered a tricky problem.
I am building a tool that monitors windows text changes using windows
hooks.
It seemed to work fine but I've try to run it over IsoBuster and it
seems that the options window and some of it's child windows set their
caption without WM_SETTEXT !!! when using SPY++ to get the options
window text before showing it the first time, it shows caption as "O",
and after show - " Options"
I've used a process wide message-monitor to chk WM_SETTEXT and I got
nada. I also went the extra mile and did an api monitor on
SetWindowText and again... nothing went by...
Does any one have a clue as to how it changes the window text WITHOUT
any message ??
thanx,
Kaniga. Tag: thanks Tag: 232904
VC++ 5.0 Linker Problem
Hi,
I'm trying to link against the wininet.lib but the linker keeps complaining that it can access part of the memory mapped space of the lib. Has anyone else come across this problem? If so is there a workaround.
P.S I know I should be using say VC++6.0 but I'm restricted to VC++ 5.0
Thanks
Rob Tag: thanks Tag: 232900
Timer problem
I am using SetTimer() function and OnTimer() function to display a window
for a certain time.
My code is as follows:
SetTimer(1,3000,NULL);
SetTimer(2,6000,NULL);
;;;
...
;;
OnTimer(nIDEvent)
{
if(nIDEvent == 1)
{
d.DoModal() //to launch a new dialog
KillTimer(1);
}
if(nIDEvent ==2)
{
d.EndDialog()//ends the dialog
KillTimer(2)
}
}
Now come the problem........this works only if you give ceratin values(here
i have give 3000 delay for first and 6000 delay for the next) This works
fine.But if you change this values....it does not work.The second setimer
should have delay equal to exact double.(say 4000 and 8000 and so on).It is
giving an asseertion error for any other value.Can anybody help.Thanks in
advance
Bye
Jeevan Tag: thanks Tag: 232899
string of ascii chars?
Hi,
I'd like to specify the string of ASCII chars, codes of which I know.
CString str = "\13" + "\10" + "\25";
^^
does not work :(
Neither works
CString str = _T("\13\10\25");
What are the possible and preferred ways to do that? Tag: thanks Tag: 232898
ICE on VC7.0 (and VC6) attempting to resolve member function pointer for a templated member function specialized by pointer-to-member-function type
Title: ICE on VC7.0 (and VC6) attempting to resolve member function pointer
for a templated member function specialized by pointer-to-member-function
type (in case Newsgroups truncates it)
I have a piece of code that is supposed to be representative of a new
function-dispatching mechanism we're trying to implement. Here it is:
<CODE>
struct DispatchParameters {};
struct DispatchReturns {};
template<class Derived> struct Dispatcher
{
typedef void (Derived::*NOPARAMFUNC)();
typedef void (Derived::*LONGFUNC)(long);
typedef void (Derived::*DISPFUNC)(NOPARAMFUNC, const DispatchParameters&,
DispatchReturns&);
template<NOPARAMFUNC>
void dispatch(NOPARAMFUNC pFunc, const DispatchParameters&,
DispatchReturns&)
{
((static_cast<Derived*>(this))->*pFunc)();
}
template<LONGFUNC>
void dispatch(LONGFUNC pFunc, const DispatchParameters&, DispatchReturns& )
{
((static_cast<Derived*>(this))->*pFunc)(1L);
}
};
struct Sink: Dispatcher<Sink>
{
void P1();
void P2(long);
const DISPFUNC f1, f2;
Sink(): f1(reinterpret_cast<DISPFUNC>(&Sink::dispatch<&Sink::P1>)),
f2(reinterpret_cast<DISPFUNC>(&Sink::dispatch<&Sink::P2>)) {}
};
int main()
{
Sink sink;
return 0;
}
</CODE>
The idea is that in real code f1 and f2 will be replaced by entries in a
map, and macros uncannily similar to ATL's SINK_MAP_ENTRY etc will be used
to specify the map. The idea of the template parameters on the overloaded
dispatch functions in Dispatcher is to allow them to be disambiguated
depending on the function signature. I realise doing reinterpret_cast on a
member function pointer is not ideal, but I believe it is going to be safe
in the way I'm actually going to use it.
On both VC6 and VC7.0, an ICE occurs. I'm hardly surprised on VC6, but I had
hoped VC7 would be able to deal with this. I don't have VC7.1, Whidbey etc
so if someone here could try it out for me on that, that would be great. The
code above compiles without error with Comeau's online compiler.
(I don't need a solution to this problem. I am raising it as a conformance
issue only.)
Visual Studio 6.0, SP5 says:
EventSinkSandpit.cpp
c:\users\strew\scratchpad\eventsinksandpit\eventsinksandpit.cpp(35) : fatal
error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)
Visual Studio 7.0 (Microsoft Visual C++ .NET 55603-652-0000007-18379)
says:
Compiling...
EventSinkSandpit.cpp
c:\Documents and Settings\strew\My Documents\Visual Studio
Projects\EventSinkSandpit\EventSinkSandpit.cpp(31) : fatal error C1001:
INTERNAL COMPILER ERROR
(compiler file
'f:\vs70builds\9466\vc\Compiler\CxxFE\sl\p1\Cxx\grammar.y', line 9326)
Comeau (www.comeaucomputing.com/tryitout/) -- No errors. Tag: thanks Tag: 232896
use precompiled header
After chosing the option "use precompiled header trougth file" and including
a standard header file stdafx.h in each header file, the compiler still
complains that cannot find the pre-compiled header.
Does anyone know how to solve the problem?
Thanks! Tag: thanks Tag: 232893
Why CMainFrame can't accept WM_COPYDATA?
Hi!
I use WM_COPYDATA in CMainFrame,
I use the ClassWizard to make following:
ON_WM_COPYDATA()
afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
The code run naturally but after "SendMessage(dlg->m_hWnd, WM_COPYDATA, 0,
(UINT)(&cds));"
it can't go into the function "BOOL CMainFrame::OnCopyData(CWnd*
pWnd,COPYDATASTRUCT* pCopyDataStruct)" why?
Thanks in advance! Tag: thanks Tag: 232890
Why CMainFrame can't accept WM_COPYDATA?
Hi!
I use WM_COPYDATA in CMainFrame,
I use the ClassWizard to make following:
ON_WM_COPYDATA()
afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
The code run naturally but after "SendMessage(dlg->m_hWnd, WM_COPYDATA, 0,
(UINT)(&cds));"
it can't go into the function "BOOL CMainFrame::OnCopyData(CWnd*
pWnd,COPYDATASTRUCT* pCopyDataStruct)" why?
Thanks in advance! Tag: thanks Tag: 232888
Why CMainFrame can't accept WM_COPYDATA?
Hi!
I use WM_COPYDATA in CMainFrame,
I use the ClassWizard to make following:
ON_WM_COPYDATA()
afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);
BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
The code run naturally but after "SendMessage(dlg->m_hWnd, WM_COPYDATA, 0,
(UINT)(&cds));"
it can't go into the function "BOOL CMainFrame::OnCopyData(CWnd*
pWnd,COPYDATASTRUCT* pCopyDataStruct)" why?
Thanks in advance! Tag: thanks Tag: 232887
File Handling and Caching
I am writing a C/C++ application that opens a set of files and reads/writes
to these files in chunks/blocks called pages.
There are two specific types of files used to store different sets of
information. There are data files used to store the logical data records
and index files used to store index references to the logical data
records in the data file.
The data file pagesize is determined by whether its storing variable or
equal size records. For this discussion, we can ignore variable length
data files and assume that data file pagesize is equal to a record size.
For the index files, the pagesize is equal to the disk's block size and
the index engine uses this to determine the number of index entries
that can exist on a single page, etc.
NOTE: The application that is handling the access to these files is
running multiple threads, so critical sections will be used to
aid in the reader/writer paradigm.
Now, if I want to be able to prevent unnecessary disk reads by implementing
some form of a page cache, is it worthwhile to spend time on developing
this "cache" functionality myself or utilize the win32 memory mapped file
logic to handle this?
By allowing the operating system to handle this, it means that I do not
have to worry about it and that I just access the file as if it were
memory pointers; however the limitation is that if the file needs to be
grown because a new record is to be added, then the file has to be
locked, unmapped, grown, remapped, and unlocked for the next operation
to take place.
By handling this myself, I then have to read the block of information
from disk, store it in memory and be able to access the memory buffer
when a thread references the page and occationally write dirty memory
buffers to disk. But this gives me the flexibility of growing the
files as needed without having to unmap/remap the file.
Both cases have their pros/cons and I was curious what others thought
would be the right avenue to go.
Thanks in advance!
Chris Tag: thanks Tag: 232886
static member variable access
Can someone explain what I'm doing wrong?
The following simple snippet illustrates my problem. The linker gives the error "unresolved external symbol 'private: static int CStaticTest::m_Count' ". I'm using VC++ 6.
class CStaticTest
{
public:
CStaticTest();
~CStaticTest();
private:
static int m_Count;
};
CStaticTest::CStaticTest()
{
m_Count++;
}
CStaticTest::~CStaticTest()
{
m_Count--;
} Tag: thanks Tag: 232880
Static class
Hi,
If we have a static class. Can we change the value of
it's member variables during the run time?
Example:
static CDbMap theMap;
Thanks, Tag: thanks Tag: 232876
MoveFile() function not working for directory?
Hi,
I want to call MoveFile() in my vc++ program to copy a directory. MoveFile() doc said the function can do it. But I tried to both the following and neither works:\
1) char sFrom = "c:\\mytest\\";
char sTo="c:\\newtest\\";
CreateDirectoryA(sTo, NULL);
MoveFileA(sFrom, sTo);
2) char sFrom = "c:\\mytest\\*";
char sTo="c:\\newtest\\";
strcat(sTo, "*");
CreateDirectoryA(sTo, NULL);
MoveFileA(sFrom, sTo);
Note sFrom is an exiting dir with files inside.
The problem is that I always got empty sTo directory, i.e. the files are never copied.
What is the problem here?
Thanks,
Peter Tag: thanks Tag: 232875
Visual C++5.0 and Windows Professional XP
Programs written with Microsoft Visual C++ 5.0 will not compile with Windows Professional XP and always
generate an error message saying that there is a missing *.dll file.
Do I have to get Visual C++.NET in order to be compatible with Windows XP I have
used the so called compatibility wizard which does not work either. Tag: thanks Tag: 232870
Question about static functions
Hey guys and girls, this is more of a alt.comp.lang.learn.c-c++ but I'm
more interested in how the VC++ .NET compiler deals with this sort of thing.
Anyways, I wanted to know what the difference between a static and a ummm...
not static 0.o function is. here's the code:
// Proto's
static int StaticGetFive(void);
int NotStaticGetFive(void);
// Func's
int StaticGetFive(void) {return 5;}
int NotStaticGetFive(void) {return 5;}
They are NOT in a class, since I know that in a class static keyword is
very different from this version (static in class makes it ummm... a none
instancible function... well... you know what i meen ~.^). My guess is that
static just ensures that the function cannot be accessed outside of the obj
file (the compiled cpp file) and that it is entirly a syntaxtical statement
(doesn't actually add or change anything in the generated assembly code). I
have been known to be wrong on occation... not often but it happends ^.~ So
I figured you guys and gurls could help my clear this up. Also I'm wondering
if this will change the way a function pointer to the function will act. I'm
guessing that since static or the ... normal version of these two functions
could still be called from outside the compiled cpp file, if we had the
right function pointer, the "NotStaticGetFive" is actually being defaulted
to a static function (since inline, or extern, etc... isn't infront of the
Prototype). Anyways, feel free to ramble on, cause any and all information
will help ;) Tag: thanks Tag: 232857
Growing and shrinking a partition
To grow a partition, this is what I use (and it works just as expected):
1. IOCTL_DISK_GROW_PARTITION, then
2. FSCTL_EXTEND_VOLUME
But now, I want to shrink a partition. Logically speaking, it's a reverse steps above, isn't it? First, to shrink the volume, then to shrink the partition. Unfortunately, neither do I find FSCTL nor IOCTL control code to shrink a partition.
Any idea? Please advice, thanks!
-P Tag: thanks Tag: 232855
coloring controls
how do i get the buttons on my control colored.Is there a way.I also want
to now if i can run small gif files on the dialog.If possible provide me
with some code.Thanks in advance .Bye
Jeevan Tag: thanks Tag: 232849
Memory leakage and the stack?
I'm using Visual C++ 6.0 and the debugger is reporting memory leaks. I go to the line it references and it is within one of my methods. The line it points to is:
rect = new CRect(0, 0, vidWidth,vidHeight);
At the very start of the method I have:
CRect rect;
I was thinking rect would be automatically deallocated on method exit. Do I have to deallocate the memory rect is pointing to? When I try either delete rect; or delete [] rect; at runtime I get a 'user breakpoint encountered' dialog box, but I set no breakpoints at the line where I delete the rect variable.
So should the memory rect points to be automatically deallocated upon method exit, and if not then why can't I delete it with the delete [] rect or delete rect statements?
Thanks!
[Tim] Tag: thanks Tag: 232844
Binary read/write to a PCMICA (PC Card)
Hi,
Anyone know how to binary read and write to
a PCMICA/PC Card/linear flash card in a laptop PC.
The card does not have a FAT and I just like to
have binary access to the whole card.
Hope some one can give me a tip.
Best regards
Tom Tag: thanks Tag: 232842
Problem in compiling a VC++ Studio Project on VC++.Net Plateform.
Hi,
I'm upgrading a VC++ Studio Project on VC++.Net Platform. In this project,
it has been used "byteSafeVector". and so related header file
"T_SafeVector.h". There is no build problem on VC++ Studio 6.0 Platform. But
when I'm compiling it on VC++.Net 2003 Platform, I find following error
messages-
d:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\T_SafeVector.h(74) : warning C4346:
'TNContainer::iterator' : dependent name is not a type
prefix with 'typename' to indicate a type
d:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\T_SafeVector.h(119) : see reference to class
template instantiation 'T_SAExtractScaler<TNContainer,TNDataType>' being
compiled
d:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\T_SafeVector.h(74) : error C2061: syntax error
: identifier 'iterator'
Obviously I can't modify the header file by prefixing typename at those
errors & warning places.
These errors & warning are in following way in T_SafeVector.h
//t_safevector.h file
....
void GetFromContainer
(
TNContainer& _cont,
void * pData,
TNContainer::iterator walk, <=warning C4346: 'TNContainer::iterator' :
dependent name is not a type
......
.....
Kindly help me.
Ram Kumar Tag: thanks Tag: 232841
Use SEH error
When trying to use SEH in VC++, it gives an "error C2712: Cannot use __try
in functions that require object unwinding."
What's the cause of the error?
What's "object unwinding"?
Thanks! Tag: thanks Tag: 232835
bitfield optimizations
Hi, everybody.
Is it possible to tell vc compiler to ignore bitfields, that
is to treat them just as normal variables? I need to run
purify on my program and in trips over all the variables
that are packed into bitfields saying it is an uninitialized
memory reference.
There are so many messages like this, that to track real
UMRs is impossible.
thanks in advance Tag: thanks Tag: 232828
Using excel automation with a namespace
I am doing Excel automation. If I include the .h file for Excel in a .h
file as below I get error messages like: error C2011: '_Application' :
'class" type redefinition. _Application is an Excel class defined in
excel9.h.
#include "..\eserver\excel9.h" // needed for excel
Thinking that this name conflicted with another name I wrapped the excel.h
with a namespace as below to avoid the conflicts.
namespace excel {
#include "..\eserver\excel9.h" // needed for excel
}
This produces errors like:
error LNK2019: unresolved external symbol "public: struct IDispatch *
__thiscall excel::_Application::GetWorkbooks (void)"
(?GetWorksbooks@_Application@excel@@QAEPAUIDispatch@@XZ) referenced in
function "public: bool __thiscall
CPrintOrder::custom_order_form_create_pages_excel(void)"(?custom_order_form_
create_pages_excel@CPrintOrder@@QAE_NXZ)
If I put the excel.h include in a .cpp file it compiles and links fine. I
prefer it to be in the .h file because I want to share a structure that
contains Excel objects in it.
What is causing the problems with the type redefinitions?
If I use the namespace excel why is the linker objecting to that and how do
I get around it?
===================================================
Zachary Hilbun
Software Consultant http://www.vianova.com
Via Nova OpenGL, Open Inventor 3D products, Windows 95/NT
Dallas, Texas VC++, C#, embedded systems, VxD's
1977 SSII SRX31185
G30 Tag: thanks Tag: 232827
Socket question....
Hi,
I came across this wierd situation recently:
One of our cutomers, has dual NIC cards on all of their machines. The NIC
cards are "Teamed" to provide extra bandwidth and fault tolarence. These are
Broadcom NetXtreme Gigabit Ethernet cards running on driver v2.78.
When our software is run on these machines, the machine stops responding
after some time (approx 13-14 mins). The machine cannot be pinged as well.
If our software is run on the same machine without the "Teaming", i.e. only
one nic card is used, it runs fine. The OS was windows 2000 server in both
the cases.
Our software makes use of SOAP and windows socket to comminucate with other
servers.
Is this a know pattern? Does any body have any idea how to resolve this
issue?
Thanks in advance.
Regards,
Soumitra. Tag: thanks Tag: 232826
CreateProcessAsUser (error 1314)
I have a problem with CreateProcessAsUser. It always returns me the error
code 1314 ("A required privilege is not held by the client").
My application needs to change the privileges to administrator privileges of
the current process. So I use ImpersonateLoggedOnUser
(this part goes well). Besides, it has to launch several commands, so I have
to use CreateProcessAsUser (because I saw that ShellExecute
or WinExec don't inherit privileges).
To create the new process I duplicate the token that use to Impersonate
converting it to primary token. Furthermore, I put the
SE_ASSIGNPRIMARYTOKEN_NAME and SE_INCREASE_QUOTA_NAME on token, because I
read that it needs, but nothing happens. The error is still here.
Does anyone can help me? What it's happening? How can I resolve it?
Here it's the code that I use:
if (!RevertToSelf()) return false;
// Get the current process token handle...
if( !OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY, &hToken ))
return false;
if (!SetPrivilege(hToken, SE_TCB_NAME, true))
return false;
if (LogonUser(szUsername, szDomain, szPassword, LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT, &hAdminUser))
bUserAuth = true;
else
bUserAuth = false;
if (bUserAuth)
{
if (!ImpersonateLoggedOnUser(hAdminUser))
MessageBox(NULL, TEXT("Inpersonate Error"), TEXT(""), MB_OK);
/////////////////////////////////////////////////
if (DuplicateTokenEx(hAdminUser, MAXIMUM_ALLOWED, 0, SecurityImpersonation,
TokenPrimary, &hAdminPriv) == 0)
MessageBox(NULL, TEXT("duplicate token Error"), TEXT(""), MB_OK);
if (!SetPrivilege(hAdminPriv, SE_ASSIGNPRIMARYTOKEN_NAME, true))
{
MessageBox(NULL, TEXT("SetPrivilege Error"), TEXT(""), MB_OK);
return false;
}
if (!SetPrivilege(hAdminPriv, SE_INCREASE_QUOTA_NAME, true))
{
MessageBox(NULL, TEXT("SetPrivilege Error"), TEXT(""), MB_OK);
return false;
}
TCHAR szRes[MAXSTRINGLEN];
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
my_strcpy(szRes, TEXT("C:\\Archivos de programa\\Inquiero Installable
ISD\\prova.exe"));
if (!CreateProcessAsUser(hAdminPriv, NULL, szRes, NULL, NULL, TRUE,
DETACHED_PROCESS|IDLE_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
TCHAR szError[MAXSTRINGLEN];
wsprintf(szError, TEXT("%d"), GetLastError());
MessageBox(NULL, szError, TEXT(""), MB_OK);
}
} Tag: thanks Tag: 232817
Template code works with g++ but not MSVC++
The following code:
class ABC
{
std::list<ABC> mylist;
};
compiles in g++ without a problem. However, VC++ version 6 (latest service
pack), complains about the class ABC not being defined on the line where the
list is declared.
I tried adding a
class ABC;
statement before the class definition, but it had no effect. I understand
this problem is due to the fact that the template parameter of mylist is in
fact the class of which mylist is a member.
Is this a problem in microsoft's implementation, or is this normal behaviour
and the fact g++ accepts it is an extension? Are there any simple
workarounds? I need to get this code to work with both compilers.
Thanks
Pierre Tag: thanks Tag: 232812
Add a control to a single cell of DataGrid
Hi all,
is it possible to add a control of my choise (e.g., ComboBox or Button) to a single cell of a Forms::DataGrid?
I understand how to add a control for a whole column. But I want to add, say, a button in cell (3,4), without having buttons in all of column 4.
Thanks,
Matt. Tag: thanks Tag: 232794
Link error when using standard functions in VS.NET Assembly
in a window or console app in VS.NET2003, I have no problem to use
unsigned char *data;
data=(unsigned char *)malloc(2000);
But in an Assembly, when compiling it, I got
error LNK2001:unresolved symbol "void* __cdeclmalloc(unsigned int)" (?malloc@@J0YAPAXI@Z)
fatal error LNK1120: 1 unresolved externals
when using File _open(...) or _read(...), I got similar problem.
Can you tell why and how to fix?
Thanks
Keith Tag: thanks Tag: 232782
RAS Client
I desperatly need to make some client software for my ISP. I
have tried using RAS from VB.NET and C# with no luck, and so I have to
turn to C++. As some have seen, I'm not the greatest with C++ yet, so
I was wondering if anyone had a good example of makeing a C++ wrapper
for RAS that I can export the function to call from VB/VB.NET or C#.
Thank You,
Tibby Tag: thanks Tag: 232781
get a window handle from an Instance handle
Hi,
I got some difficulties in getting a window handle from an instance handle
in Win32 API/C. I used the approach stated in the knowledge base article
242308 -- how to find a window handle from an instance handle, but I found
nothing even though I went through the whole window (TOP level windows)
handles.
I found the instance handle is a 9-digit long integer, and the other
process IDs returned by GetWindowThreadProcessId are only three or four
digits long. Is it normal?
I appreciate your any ideas!
Hu Tag: thanks Tag: 232778
Handle to a Process's Window
Does anyone know how to get the window handle to a processes main window? I
create a process using CreateProcess and I would like to destroy it by
sending a WM_QUIT message to the main window. Thanks. Tag: thanks Tag: 232774
Embed an exe inside an ActiveX control ?
Hi:
Anyone knows how to embed an exe file inside an ActiveX control ? I would
like the activex control to be downloaded and execute the exe file on the
user machine.
Thanks in Advance
Polaris Tag: thanks Tag: 232772
Template template argument
I am sorry if this has been asked before, I couldn't find it right
away, that's why I'm posting here.
This code:
---------------------
template <typename NumType, template <typename T> class DerivedType>
class Matrix {
public:
NumType operator()( const int row, const int col ) const;
NumType& operator()( const int row, const int col );
};
template <typename NumType>
class GeneralMatrix : public Matrix<NumType, GeneralMatrix> {
public:
GeneralMatrix(int,int) {}
};
int main()
{
GeneralMatrix<double> matrix(3,3);
matrix(1,1) = 2.0;
}
----------------------
VC++ 7.1 refuses to compile complaining about the use of 'GeneralMatrix'
as the second argument to 'Matrix' in the template definition. Is that
a [known] bug or am I missing something?
The situation came up while I was answering a question about operator(),
not about template template arguments, but still...
Thanks.
Victor Tag: thanks Tag: 232746
Get Accont type.
Hi all,
I need know if the current user loged have a administrator privilegies?
How I get this.
Get account of currente user.
Thanks Tag: thanks Tag: 232741
.def file and C++
Hi,
I have a question about the "C++" symbol export.
Is it possible to export some "C++" symbols (classes)
using .def file (instead of __declspec(dllexport)) ?
Thanks
George Tag: thanks Tag: 232734
Format and quick format
Hi,
What's the windows API to perform formatting or quick formatting of a floppy, a partition, or a volume?
Please advice, thanks!
-CL Tag: thanks Tag: 232733
user defined data type in com dll
Hello
I am writing a com dll, i am trying to use a structure variable
in on of the interface but it gives me error on compilation. I just wanted
to know whether i can use user defined data types in interface of com dll.
[id(5), helpstring("method GetData")] HRESULT GetData([in] WAYPOINTS &wp);
I get the following error
expecting a type specification near "WAYPOINTS" Tag: thanks Tag: 232730
Perl syntax coloring in Visual Studio 6.0
Hi,
Does anyone have the usertype.dat file for the perl syntax ?
Does anyone knows a different way to highlight the perl syntax in
visual studio 6.0 ? Tag: thanks Tag: 232728
Dialogbox did not show up. Please help!!!
Hi,
I am implementing a Win32 DLL project. In this dll I developed a dialogbox.
In order to export the dialogbox, I did the following things.
1. define a function called Test()
int Test() {
return DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG),NULL, DlgProc);
}
2. export this Test() function.
The problem I encountered was the dialogbox did not show up. The DialogBox()
returned a -1 indicating it failed to create the dialogbox. So I called
GetLastError() and got the error code 1812, which indicates "The specified
image file did not contain a resource section.".
I am pretty sure the Test() function was successfully exported because I got
some results if I replace the DialogBox() with other functions.
I stuck there for tens of hours so if you have any clues or ideas, please
drop me a line. I deeply appreciate your help.
THanks,
Hu Tag: thanks Tag: 232717
VC++ standard compliance
Is it legal to compile the attatched code? More specificlly, are the calls
to f() properly resolved? Please explain why in either case.
begin 666 main.zip
M4$L#!!0``@`(`'(-ZS!4`K)IL@```%H"```(````;6%I;BYC<'"]D,T.@C 0
MA,]MTG?8(Q CGLM)PEF?H:W\-(%B^J,'P[N[!4),O(J;7F:FFW[3//_I,,JH
MZH5S4#+Z8O0>9*\59Y0\1GV#)H$4U&B<!]_9\8D2([Q')D:G(F[G>P%5P&'!
M^6+#$YPV+92<-\5B;+Q_`-3&PR"T833!EU 10BYAD+6]-F?;AJ$VWATP4IVP
M64;(9LZLZ5R'5" BNSA&ZK5%M?ZVC%I^)K;VP1HXH9QVJ?4&4$L!`A0`% `"
M``@`<@WK,%0"LFFR````6@(```@``````````0`@( ```````&UA:6XN8W!P
64$L%!@`````!``$`-@```-@`````````
`
end Tag: thanks Tag: 232715
Static libs
Hello all !
I want to create a static lib. In it, i'm calling
a function (lets say 'xzy') that is in another static lib...
So I included it in the project and I compiled...
it compiled fine..
When I write a client that uses my lib, it complains
that it cannot link the 'xyz' function (unresolved)... So
the client have to include the lib where 'xzy' is implemented...
Is there a way for the function body 'xyz' be included
in my static lib so that clients that will use my lib won't
have to include all other libs that my lib uses !?
Mike Tag: thanks Tag: 232709
Slow file transfer ...
Hi,
I am writting a program using WinSock2 to transfer files, the program seems work fine when the file is not that big. But when I tried it with a 370M file, it's too slow that I can tell the transferrred file increase it's size about 1200byte each time.
I used TransmitFile() in putting file, here is how I use the function:
if(!TransmitFile( m_socket, hFile, 0, 0, NULL, NULL, 0 ))
{
CloseHandle(hFile);
throw CCException( CWsaerr(), WSAGetLastError(), _T("Falied to transmit file") );
}
I am not sure if the slow transfer is from this function call. Even I increase the buffer size of receiving side (I used recv() ), it seems no effect. So I suspect it. One of my collegues said MTS may limit the transfer to about that speed, but I am not sure.
Any idea? If TransmitFile() does cause this slowing down, any ways to fix it? Or I have to go back to use traditional send() to send? Any comments or suggestions?
Thanks,
Peter Tag: thanks Tag: 232699
richedit(?1) + windows 98 + em_replacesel = codepage problem
I have richedit (control) with some russian text in it.
Then I make a selection - SendMessage(Handle, EM_EXSETSEL, 0, ...));
And then I replace a selection - SendMessage(Handle, EM_REPLACESEL, 0,
buffer) with some russian text.
The result is OK on windows2000 and NT, but on windows 98(russian edition)
inserted text is in wrong codepage (appeared as unreadable abracadabra).
so help me please.
--
--- With best wishes, Kirill.
* ...chasing dreams... Tag: thanks Tag: 232684
deadlock on SMP machines - perhaps caused by wldap32.dll?
Hello,
Apologies in advance, this is a very long post, but I'm trying to be
as complete as possible. I'm also not sure if this is the correct
group, but it seemed appropriate.
We have a process that runs as part of our product that has been
working fine on Windows. However, we recently had an issue onsite
where these processes (there are usually multiple instances) would
hang and become completely unresponsive on SMP (Compaq 8-way) machines
running Windows NT and 2000. I've managed to recreate the issue in our
test lab on a dual Xeon (hyperthreaded) box running Windows 2003.
There is definitely some sort of deadlock situation here, but I'm at a
loss how to proceed after banging my head against this for a week now.
There is some evidence that suggests the DllInit function of wldap32
is somehow a player in this - the details are further down.
First, let me provide a little context: This service (it's not really
an application) is written in VC++ 6.0, and is spawned via a daemon
that is also part of our application. In a typical deployment there is
one of these service processes for each processor on the local
machine. The service instantiates a Java Virtual Machine via JNI, and
most of our core code executes within the VM.
One of the functions of this service is to spawn processes and feed
them input and capture their output. This is acheived by the VM
loading a VC++ 6.0 bridge library, which in turn loads another VC++
6.0 library (we'll call this the "work library") which does the actual
work. When all of the assigned work is through, the work library is
unloaded until the next time. The work library is fairly simple, and
the core behavior involves invoking CreateProcess (usually cmd.exe,
which in my test setup just echoes some msg), and creating threads to
write to the input handle, and read from the output and error handles.
This has been working on all flavors of Windows (uniprocessor) for
quite some time.
Now, to the details. Here is the basic sequence leading up to the
hang:
1) Process loads the work library
2) Process performs some number of brief "work units" (CreateProcess()
+ accompanying threads, and then cleanup) happily and healthily
3) Process CPU utilization drops to 0, and there is no more activity,
ever. This lockup appears to happen faster when more instances are
running.
Attaching cdb to these hung processes consistently reveals two
scenarios:
Scenario A - the "Is wldap32.dll doing something bad?" scenario
----------
The work library thread which called CreateProcess has successfully
waited on the process to exit. It waits on an Event that will be set
by the thread which reads the output from the process, but that Event
is never set. Mainly because those helper threads are stuck. The
debugger always has to forcibly break into the process b/c the loader
lock is held.
!locks reveals two locks in contention:
CritSec ntdll!LdrpLoaderLock+0 at 77FC2340
LockCount 8
RecursionCount 1
OwningThread b80
EntryCount 2a
ContentionCount 2a
*** Locked
CritSec WLDAP32!PerThreadListLock+0 at 76F34010
LockCount 1
RecursionCount 1
OwningThread d64
EntryCount 1
ContentionCount 1
*** Locked
----
Stack trace for thread b80:
0f5dfba8 77f43741 77f5d64e 000005a0 00000000
SharedUserData!SystemCallStub+0x4
0f5dfbac 77f5d64e 000005a0 00000000 00000000
ntdll!ZwWaitForSingleObject+0xc
0f5dfbe8 77f42044 000005a0 76f1129f 76f34010
ntdll!RtlpWaitForCriticalSection+0x126
0f5dfbf0 76f1129f 76f34010 00000000 0f5dfc1c
ntdll!RtlEnterCriticalSection+0x46
0f5dfc00 76f11257 00000b80 77f47dc9 76f10000
WLDAP32!AddPerThreadEntry+0x2f
0f5dfc08 77f47dc9 76f10000 00000002 00000000 WLDAP32!LdapDllInit+0x3e
0f5dfc28 77f5d067 76f11180 76f10000 00000002
ntdll!LdrpCallInitRoutine+0x14
0f5dfcbc 77f5cef6 0f5dfd30 0f5dfd30 00000000
ntdll!LdrpInitializeThread+0xd4
0f5dfd1c 77f45241 0f5dfd30 77f40000 00000000
ntdll!LdrpInitialize+0x171
00000000 00000000 00000000 00000000 00000000
ntdll!KiUserApcDispatcher+0x7
To me, this begs the question: why is this library referred to in the
first place? We certainly don't use LDAP and we aren't using
ActiveDirectory, either. 'lm' reveals that it is an unloaded module.
My only guess is that the library init routine is called in order to
see if LDAP is enabled in case it's needed to check process/thread
creation security tokens.
The interesting thing about WLDAP32!PerThreadListLock+0 is that the
owning thread (d64) is nowhere to be found! So, no stack trace.
There are several other threads waiting on locks. None of them are in
my input/output/error read/write user code, they are all in
LdrpInitialize or kernel32!ExitThread. I suspect the exiting threads
are mine.
5 threads have the same trace (with differing addresses, but waiting
on the same critical section - 77fc2340):
0f6dfbec 77f43741 77f5d64e 00000330 00000000
SharedUserData!SystemCallStub+0x4
0f6dfbf0 77f5d64e 00000330 00000000 00000000
ntdll!ZwWaitForSingleObject+0xc
0f6dfc2c 77f42044 00000330 77f5cfcc 77fc2340
ntdll!RtlpWaitForCriticalSection+0x126
0f6dfc34 77f5cfcc 77fc2340 00000000 7ffdf000
ntdll!RtlEnterCriticalSection+0x46
0f6dfcbc 77f5cef6 0f6dfd30 0f6dfd30 00000000
ntdll!LdrpInitializeThread+0x2f
0f6dfd1c 77f45241 0f6dfd30 77f40000 00000000
ntdll!LdrpInitialize+0x171
00000000 00000000 00000000 00000000 00000000
ntdll!KiUserApcDispatcher+0x7
And here are the exiting threads:
c18:
----
0e0dfe70 77f43741 77f5d64e 00000330 00000000
SharedUserData!SystemCallStub+0x4
0e0dfe74 77f5d64e 00000330 00000000 00000000
ntdll!ZwWaitForSingleObject+0xc
0e0dfeb0 77f42044 00000330 77f7c658 77fc2340
ntdll!RtlpWaitForCriticalSection+0x126
0e0dfeb8 77f7c658 77fc2340 00000000 7ffa4000
ntdll!RtlEnterCriticalSection+0x46
0e0dff44 77e57eb3 00000000 0c0bd418 00a87b88
ntdll!LdrShutdownThread+0x30
0e0dff7c 77bc917d 00000000 77bc91f3 00000000 kernel32!ExitThread+0x41
0e0dff84 77bc91f3 00000000 00000000 00000000 msvcrt!_endthreadex+0x25
0e0dffb8 77e4a990 00a87b88 00000000 00000000 msvcrt!_endthreadex+0x9b
0e0dffec 00000000 77bc917e 00a87b88 00000000
kernel32!BaseThreadStart+0x34
9cc:
----
0e1dfe70 77f43741 77f5d64e 00000330 00000000
SharedUserData!SystemCallStub+0x4
0e1dfe74 77f5d64e 00000330 00000000 00000000
ntdll!ZwWaitForSingleObject+0xc
0e1dfeb0 77f42044 00000330 77f7c658 77fc2340
ntdll!RtlpWaitForCriticalSection+0x126
0e1dfeb8 77f7c658 77fc2340 00000000 7ffa3000
ntdll!RtlEnterCriticalSection+0x46
0e1dff44 77e57eb3 00000000 0b2e6c48 0b38b590
ntdll!LdrShutdownThread+0x30
0e1dff7c 77bc917d 00000000 77bc91f3 00000000 kernel32!ExitThread+0x41
0e1dff84 77bc91f3 00000000 00000000 00000000 msvcrt!_endthreadex+0x25
0e1dffb8 77e4a990 0b38b590 00000000 00000000 msvcrt!_endthreadex+0x9b
0e1dffec 00000000 77bc917e 0b38b590 00000000
kernel32!BaseThreadStart+0x34
I can provide further information if it is needed.
-------------------------------------------------------------------------------
Scenario B - the "what happened to the malloc lock?" scenario
----------
As in scenario A, the work library thread which called CreateProcess
has successfully waited on the process to exit. It waits on an Event
that will be set by the thread which reads the output from the
process, but that Event is never set. These helper threads are also
stuck, but this time they are actually in user code. The debugger does
not have to forcibly break into this process.
!locks only reveals one lock in contention:
CritSec MSVCRTD!__app_type+34 at 10264780
LockCount 1
RecursionCount 0
OwningThread 0
EntryCount 4
ContentionCount 4
*** Locked
The owning thread is 0. Uh oh. My two helper threads also happen to be
waiting on this lock:
ea8:
----
0f2eed90 77f43741 77f5d64e 00000680 00000000
SharedUserData!SystemCallStub+0x4
0f2eed94 77f5d64e 00000680 00000000 00000000
ntdll!ZwWaitForSingleObject+0xc
0f2eedd0 77f42044 00000680 1020b5a3 10264780
ntdll!RtlpWaitForCriticalSection+0x126
0f2eedd8 1020b5a3 10264780 0f2eeec4 0f2eee18
ntdll!RtlEnterCriticalSection+0x46
0f2eede8 1021352a 00000009 0f2efed8 0f2eee74 MSVCRTD!_lock+0x93
0f2eee18 102134ce 0de09de0 00000001 0f2eee34 MSVCRTD!_free_dbg+0x2a
0f2eee28 104bd0ed 0de09de0 0f2eee44 104ad0f0 MSVCRTD!free+0xe
0f2eee34 104ad0f0 0de09de0 0f2eeec4 0f2eee5c MSVCP60D!operator
delete+0xd
0f2eee44 1048be9e 0de09de0 00000021 ffffffff
MSVCP60D!std::allocator<char>::deallocate+0x10
0f2eee5c 10489b71 00000001 0f2eeec4 0f2efee4
MSVCP60D!std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::_Tidy+0x6e
0f2eee6c 0c0e3c99 0f2eff74 0f2efeec 0de09ce0
MSVCP60D!std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::~basic_string<char,std::char_traits<char>,std::allocator<char>
>+0x11
0f2efee4 0c0d9ddb 00000000 00000000 0de09ce0
worklib!NullCopyRunner::run+0x119
0f2eff84 1020bf53 0de09c98 00000000 00000000
worklib!JobThread::execute+0x4b
0f2effb8 77e4a990 0de09ce0 00000000 00000000
MSVCRTD!_beginthreadex+0x133
0f2effec 00000000 1020bee0 0de09ce0 00000000
kernel32!BaseThreadStart+0x34
7d0:
----
0f1ee64c 77f43741 77f5d64e 00000680 00000000
SharedUserData!SystemCallStub+0x4
0f1ee650 77f5d64e 00000680 00000000 00000000
ntdll!ZwWaitForSingleObject+0xc
0f1ee68c 77f42044 00000680 1020b5a3 10264780
ntdll!RtlpWaitForCriticalSection+0x126
0f1ee694 1020b5a3 10264780 00000021 0f1ee6d8
ntdll!RtlEnterCriticalSection+0x46
0f1ee6a4 102129da 00000009 00000000 0f1ee7cc MSVCRTD!_lock+0x93
0f1ee6d8 102129a6 00000021 00000001 00000001
MSVCRTD!_nh_malloc_dbg+0x2a
0f1ee6f4 1020e2cf 00000021 00000001 0f1eff44 MSVCRTD!_nh_malloc+0x16
0f1ee708 104b7a69 00000021 0f1ee728 104ad0d2 MSVCRTD!operator new+0xf
0f1ee714 104ad0d2 00000021 00000000 0f1eff44
MSVCP60D!std::_Allocate+0x19
0f1ee728 1048ba18 00000021 00000000 00000000
MSVCP60D!std::allocator<char>::allocate+0x12
0f1ee770 1048bccc 00000017 00000000 0f1eff44
MSVCP60D!std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::_Copy+0x58
0f1ee784 1048a005 00000017 00000001 0f1eff44
MSVCP60D!std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::_Grow+0x10c
0f1ee798 1048a060 0c136674 00000017 0f1eff44
MSVCP60D!std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::assign+0x15
0f1ee7ac 10489ad7 0c136674 0f1eff44 0f1eff84
MSVCP60D!std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::assign+0x20
0f1ee7bc 0c0d9e1f 0c136674 0f1eff40 1020d797
MSVCP60D!std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::basic_string<char,std::char_traits<char>,std::allocator<char>
>+0x27
0f1eff84 1020bf53 0de09ba8 00000000 00000000
worklib!JobThread::execute+0x8f
0f1effb8 77e4a990 0de09bf0 00000000 00000000
MSVCRTD!_beginthreadex+0x133
0f1effec 00000000 1020bee0 0de09bf0 00000000
kernel32!BaseThreadStart+0x34
So it appears that the malloc/heap/whatever-you-call-it lock is
somehow munged. None of the other threads reveal anything interesting.
-------------------------------------------------------------------------------
Summary: I considered the possibility of heap contamination, but using
gflags I enabled full page heap and every other form of heap checking,
but there appear to be no problems there. I am suspicious that there
is something else at work because these scenarios happen exactly the
same every time.
As I mentioned before, this code has been working perfectly on Windows
uniprocessor systems for more than a year now. The only variable is
the multiprocessor environment. I am seriously thinking that this is
system related.
I've noticed that there have been some deadlock related fixes for
wldap32.dll, including a recent hotfix that postdates the release of
Windows 2003. I'm wondering if this would fix our problem?
I eagerly await any new ideas on this issue! I am pretty much out of
them at this point. If I can provide further information on this,
please ask. Thanks for reading!
Regards,
Marc Tag: thanks Tag: 232683
Can rebasing affect correctness of information in the map file generated before?
Hi everybody
For some strange reasons offsets in dlls loaded into memory do not match
those, mentioned in map file. We suspect that this happens due to automatic
rebasing of all the binary modules involved in workspace at the end of
complete build of all the projects. Can this possibly be the case and how to
avoid it?
It looks like order of some sections is changed. Quite often offsets exceed
the last offset mentioned in the map file. We generate map file with options
/map /MAPINFO:LINES /MAPINFO:EXPORTS during building of a particular
project. Rebasing is made after all the projects were built and involves all
the modules that will be loaded:
rebase.exe -b 0x60060000 [module ...]
Kind regards,
Antonio Tag: thanks Tag: 232682
convert unsigned char array from managed to unmanaged
Do you know how to convert unsigned char array from managed to unmanaged
e.g.
unsigned char charArray __gc[]
convert it to
unsigned char charArray_[]
and vice versa
Thanks Tag: thanks Tag: 232670
deallocating vector storage
The following is a thread from c.l.c++...since the behavior is
apparantly platform-dependent, I'm looking for the best solution for
MSVC++ 6.0 and also for 7.1 if it is different.
Regards,
Ryan
Tino wrote:
> In TC++PL (third edition), Section 16.3.8, Stroustrup gives the
> following as a way to give memory from a std::vector back to the
> system:
>
> vector<int> tmp = v; // v.size() == 0
> v.swap( tmp ); // v now has capacity of tmp (default), extra capacity
> returned to system
>
> We need to have a general method that returns memory back to the
> system for vectors which are no longer needed, but have not yet gone
> out of scope. Are there alternative suggestions for accomplishing
> this?
There is no guarantee that the storage will be returned. Swapping
with
an empty vector, clearing the vector, resizing it to 0, all are good
attempts to accomplish what you need, but the Standard makes no
promises
WRT the memory allocation behaviour. It's all platform-dependent and
implementation-dependent, I believe.
V Tag: thanks Tag: 232665
Which interfaces should be referenced in coclass definition of idl file?
Hi everybody,
Is there any rule or principle based on which one can decide which
interfaces from those supported by the object to include into coclass
definition and which not? What influence does it have depending on where
component will be used: C++, Visual Basic, VBScript (Internet Explorer),
Delphi etc. ?
For example in the following case when I try to insert control into Visual
Basic, it just hangs.
[
uuid(BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB), // actual guid replaced
helpstring("MyClient class")
]
coclass MyClient
{
[default] interface IMyDualInterfaces;
[default, source] dispinterface _IMySourceEvents;
interface IMyCustomInterfaces0;
interface IDispatch;
interface IMyCustomInterfaces1;
interface IMyCustomInterfaces2;
interface IViewObjectEx;
interface IViewObject2;
interface IViewObject;
interface IOleInPlaceObjectWindowless;
interface IOleInPlaceObject;
interface IOleWindow;
interface IOleInPlaceActiveObject;
interface IOleControl;
interface IOleObject;
interface IPersistStreamInit;
interface IPersistPropertyBag;
interface IPersist;
interface ISupportErrorInfo;
interface IConnectionPointContainer;
interface ISpecifyPropertyPages;
interface IQuickActivate;
interface IPersistStorage;
interface IDataObject;
interface IProvideClassInfo;
interface IProvideClassInfo2;
interface IMarshal;
interface IObjectSafety;
interface IConnectionPointContainer;
};
Any reference to an article that might help will be greatly appreciated.
Thanks in advance,
Antonio Tag: thanks Tag: 232664
Thanks a lot buddy.Bye.Thank you once again
Jeevan