|
how i use SOM in C++ Program to modify Schema
|
|
|
|
|
|
In C# there's a Process.FindByName method. How do I do that in C++ ? I have the process name, and I want to find the HWND and send it a message.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
EnumProcesses -> OpenProcess -> GetModuleFileName
|
|
|
|
|
|
I am trying to use io completion ports in a socket server that I am working on for work.
I based a lot of my initial work on Len Holgates code and articles.
However I am running into problem with threads in the thread pool.
It all works fine for a while, and then I will get a problem where the same OVERLAPPED pointer is accessed simulataneously by 2 different threads in a pool of 5 worker threads (on a HT system with "2" CPUs). This same pointer then gets used in a WSARecv call and the contents of the first call to WSARecv get overwritten by the second call to WSARecv.
So how is it possible for two threads (out of 5) that return from a call to GetQueuedCompletionStatus() to both end up with the same OVERLAPPED pointer?
The overlapped buffer is defined as a class that inherits from OVERLAPPED (called IOBuffer).
This class is created for each new read/write call. The allocater used is the C++ standard new function.
Thanks in advance!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Without seeing the code i think it's going to be hard for anyone to help.
I've written my own IOCP code and never had this problem.
Is your system setup to only have one outstanding recv per connection, or multiple (as Len does in his later articles).
What is the order of ops in your server code, is it something like:
- accept new connection
- create new overapped structure
- post overlapped recv
- ... (wait)
- iocp thread returns from GQCS() with overlapped structure
- (then what - reuse structure, delete structure, ...)
...cmk
Save the whales - collect the whole set
|
|
|
|
|
OK, sorry about the lack of details
- app accepts a new connection
- app requests a read
- create an new overlapped struct
- mark struct as a read request
- post to io completion port
- iocp thread waits
- iocp thread returns from GQCS() with overlapped ptr
- check state of overlapped struct
- if read requests then do a WSARecv
- if WSARecv returns 0 or io pending mark overlapped as read complete
other wise mark as read error
- iocp thread waits
- iocp thread returns from GQCS() with overlapped ptr
- check state, if read complete push overlapped ptr to event list, notify app
- iocp thread waits
- app recvs message, pops last overlapped ptr off event list
- app process buffer data associated with the overlapped ptr
- app deletes buffer
- app deletes overlapped
- app requests a read
etc
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Nothing jumps out as being obvious.
The only thing i can think of is that where you have WSARecv() == 0 ... mark as read complete, a handling thread may return from GQCS() right away with the OVERLAPPED structure.
That is, if you aren't syncing data access, the first thread that is marking the OVERLAPPED as read complete is racing with the GQCS() handling thread.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
OK, so if I understand you correctly, I need some sort of mutex/critical section that is common to all the iocp threads, or one CS/mtx per overlapped ptr?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Well, i don't.
I just let the GQCS() threads handle all overlapped ops - including those that complete right away (as indicated by return of 0).
You should be able to set break points and walk through the code to see if you are having your posting thread and GQCS() thread racing to modify your overlapped struct.
From what you have shown i might try changing the following:
- if read requests then do a WSARecv
- if WSARecv returns 0 or io pending mark overlapped as read complete
other wise mark as read error
to,
- if read requests then clear request flag and do a WSARecv
- if WSARecv returns 0 or io pending mark overlapped as read complete do nothing,
other wise mark as read error
- when GQCS() get overlapped structure for completed read ... notify app ...
...cmk
Save the whales - collect the whole set
|
|
|
|
|
i have written a simple code using the MSDN code of GETComputerName in Windows 2000 but it is not running in the execution (it complies and builds normally) stating "memory access violation " message saying the "memory cannot be written .
The sample code is
#include<windows.h>
#include<stdio.h>
const int BUFFER=100;
int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR c,int n)
{
LPTSTR lpszSystemInfo; // pointer to system information string
DWORD cchBuff = 256; // size of computer or user name
CHAR tchBuffer[BUFFER]={0,0,0,0,0,}; // buffer for expanded string
int nSize; // size of string
GetComputerName(lpszSystemInfo,&cchBuff);//get Computer Name
nSize = sprintf(tchBuffer, "Computer name: %s",
lpszSystemInfo);
MessageBox(0,tchBuffer,"Computer Name",0);
return 0;
//please debug it for me thanks// Nish take note plz
|
|
|
|
|
You do not have the correct sets of buffer created.
You did not allocate any space for the computer name to be stored.
int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR c,int n)
{
TCHAR szName[256]; // pointer to system information string
TCHAR szBuffer[512]; // buffer for expanded string
int iTextLength;
// GetComputerName expects number of characters, not bytes
iTextLength = sizeof(szName)/sizeof(TCHAR);
//get Computer Name
GetComputerName(szName, &iTextLength);
iTextLength = sprintf(szBuffer, "Computer name: %s", szName);
MessageBox(0, szBuffer, "Computer Name", 0);
return 0;
}
|
|
|
|
|
hello to all members
i am making vc++ desktop service application. this application communicate with clients on the port 3310.
i want to exchange data through SOAP objects. how can my service read and
reponse to client using SOAP.
i am new in vc++ services so i don't know how to handle this type of programming. please help me to sortout my problem.
Plz Help
thanks in advance.
ankit
|
|
|
|
|
Hi
I have downloaded AESLib-3.1.zip from URL : http://www.copera.com/AESLib/
In that there is one file called AESLibARMlet.c in which last portion is like
------------------------------
#ifndef WINDLL
#ifndef __USE_THUMB__
void setr10(void* gotP)
{
asm ("mov r10, r0");
}
#else
void setr6(void *gotP)
{
asm ("mov r6, r0");
}
#endif
---------------------------
Now when I try to include all this files into my own DLL file and compile it, it gives one warning which is :
\aeslibarmlet.c(254) : warning C4013: 'asm' undefined; assuming extern returning int
Any idea why this error occurs? though I have included all the header files which needed. Also I have searched for function "asm" into all files but it exist no where.....so what should I do....to remove this error....
Plz Help me, It's urgent
MacCloony
|
|
|
|
|
Amarelia wrote:
\aeslibarmlet.c(254) : warning C4013: 'asm' undefined; assuming extern returning int
Try __asm instead. I don't think the parenthesis, quote marks, or semicolon are needed.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thankx a lot
I tried removing parenthesis, quote marks, semicolon and also __asm. but it's not working and showing error as :
c:\wrkspace\vc++\xyztools\aeslibarmlet.c(255) : error C2415: improper operand type
Any idea why it happens ?
Plz
Thankx in advance
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Amarelia wrote:
c:\wrkspace\vc++\xyztools\aeslibarmlet.c(255) : error C2415: improper operand type
Any idea why it happens ?
Without seeing the actual code, I'm afraid not. My first guess is that the r10, r0, and r6 operands are unknown to the compiler. They don't look Intel-ish to me.
What exactly are you trying to accomplish?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
They are "intel-ish"!. These are x86-86 registers, like RAX, EBX, ...
The Microsoft x86-64 compiler does not support x86-64 inline assembler yet!
Don't try it, just do it!
|
|
|
|
|
This assembler code is x86-64. As far as I know the x86-64 compiler of Microsoft does not support inline assembler yet.
Don't try it, just do it!
|
|
|
|
|
Hi everyone. I need some help on this: I am using wininet funcs to "talk" to a http server. I am opening a root handle with InternetOpen (ret code OK), than I call Internetconnect (ret code OK). I am openning then a request handle, with HttpOpenRequest:
<br />
void CfileURL::OpenRequest()<br />
{<br />
LPCTSTR lpszVerb = "GET";<br />
LPCTSTR lpszObjectName = "/avcenter/venc/data/w32.kelvir.c.html";<br />
LPCTSTR lpszVersion = NULL;
LPCTSTR lpszReferrer = NULL;
LPCTSTR lplpszAcceptTypes =("Accept : */* ""Accept-Ranges: bytes");<br />
DWORD dwOpenRequestFlags = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP |<br />
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |<br />
INTERNET_FLAG_KEEP_CONNECTION |<br />
INTERNET_FLAG_NO_AUTH |<br />
INTERNET_FLAG_NO_AUTO_REDIRECT |<br />
INTERNET_FLAG_NO_COOKIES |<br />
INTERNET_FLAG_NO_UI |<br />
INTERNET_FLAG_RELOAD;<br />
DWORD dwOpenRequestContext = 0;<br />
<br />
<br />
m_h_Request = HttpOpenRequest(m_h_URL, lpszVerb, m_URL.object_name, lpszVersion,<br />
lpszReferrer, (LPCTSTR *) &lplpszAcceptTypes,<br />
dwOpenRequestFlags, dwOpenRequestContext);<br />
<br />
<br />
DWORD err=GetLastError();<br />
<br />
return err;<br />
}<br />
then i make
char ah[] = "Range: bytes=0-30";
bool bResult = HttpAddRequestHeaders(m_h_Request, ah, strlen(ah), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
and then i send the request with HttpSendRequest, to determine if the server accepts bytes range. I get the status code 206 (partial content) (for the server I use) which is ok for me. I close the m_h_Request handle obtain from the previous call to httpopenhandle.
Then I make a new request, to determine the file size:
bool bret = OpenRequest();
bool bResult = HttpSendRequest(m_h_Request, NULL, 0, NULL, 0);
DWORD dwSize = sizeof(DWORD);
DWORD infolevel = HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER;
if (!HttpQueryInfo(m_h_Request, infolevel, &m_dwflen, &dwSize, NULL))
DWORD qi = GetLastError();
then i close the handle m_h_Request (httpopenrequest)
at this point i have determined the file size, which is ok,
BUT
when i try to open a new request with the above function i get ret code 122 which is ERROR_INSUFFICIENT_BUFFER. What i do not understand is why at first two calls OpenRequest returned ok, and now it returns 122.
If anyone can tell me which is the right way to use the httpOpenrequest, handle (should i or i should not close the handle after each request, than open it again for a new request) please do so.
Any help is wellcome.
THANKZ:->
|
|
|
|
|
Hi,
I have an application which sends BMP file data to the printer using BitBlt(). The bitmap data is passed to the printer DC.
if (!BitBlt(m_hdcPrint, nXDest, nYDest, nWidth, nHeight, hdcTemp, 0, 0, SRCCOPY))<br />
{<br />
... Report error<br />
}
My application works fine under Win XP/2000, but fails under Win 98SE. Can anyone help me in this? My printer supports BitBlt(). I am checking it with GetDevCaps().
If I make the application to give a TextOut(), it works fine. The LineTo() function also fails.
Kindly help me.
Thanks
Vini
|
|
|
|
|
Does anybody know how to add memory to a read only CEdit ?
|
|
|
|
|
|
the real problem -
I use an object called "CEditEx" (available also in this side i reckon), as a terminal for serial communication with some device. Anyway - after filling 200 lines, i have the following code that maintain the history :
if(mainWnd->m_textBoxOut.GetLineCount() > 200) {
textBegin = mainWnd->m_textBoxOut.LineIndex(1);
mainWnd->m_textBoxOut.SetSel(0,-1);
mainWnd->m_textBoxOut.GetWindowText(entireText);
entireText = entireText.Right(entireText.GetLength()-textBegin);
mainWnd->m_textBoxOut.ReplaceSel(entireText);
}
Where "m_textBoxOut" is the CEditEx object and "textBegin" is an integer for keeping an index.
THE PROBLEM is that when executing this code, the display of the CEdit object flashes (since it re-writes itself).
Any idea ?
Thanks
Timor
|
|
|
|
|