|
I want to create some file mapping with CreateFileMapping() API.My problem is that when a file is open by other procces it can not create mapping and return NULL handle for it.So how can I map shared files or how can I find out is open by other process?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Hi,
I have a data structure as followings. I need that insert some
data in order to make the data looks completely. In the data,
the x[0], x[1], x[2] and x[3] are timecode: represents hour, minutes, second and frame (here 1 second = 30 frames), respectively. The other important data is x[5], when you insert some new timecode with contimuous frame, the x[5] should also be inserted with a Linear insert method. The rest data should be same with others.
I found that it is slowly when the length of the data is large. So
is there a fast method for doing this ?
The data looks like this:
------------------------------------------------------------
x[0] x[1] x[2] x[3] x[4] x[5] x[6], ... x[13]
00 02 14 19 0 41 0 4 2 3 0 15 15 0
00 02 14 20 0 42 0 4 2 3 0 15 15 0
00 02 14 22 0 44 0 4 2 3 0 15 15 0
00 02 14 23 0 46 0 4 2 3 0 15 15 0
00 02 14 25 0 47 0 4 2 3 0 15 15 0
00 02 14 26 0 48 0 4 2 3 0 15 15 0
00 02 14 27 0 49 0 4 2 3 0 15 15 0
00 02 14 28 0 50 0 4 2 3 0 15 15 0
00 02 15 00 0 51 0 4 2 3 0 15 15 0
00 02 15 01 0 53 0 4 2 3 0 15 15 0
00 02 15 02 0 54 0 4 2 3 0 15 15 0
00 02 15 03 0 56 0 4 2 3 0 15 15 0
00 02 15 04 0 57 0 4 2 3 0 15 15 0
00 02 15 05 0 58 0 4 2 3 0 15 15 0
00 02 15 06 0 59 0 4 2 3 0 15 15 0
00 02 15 07 0 60 0 4 2 3 0 15 15 0
00 02 15 08 0 61 0 4 2 3 0 15 15 0
00 02 15 09 0 63 0 4 2 3 0 15 15 0
00 02 15 10 0 64 0 4 2 3 0 15 15 0
00 02 15 12 0 68 0 4 2 3 0 15 15 0
00 02 15 13 0 69 0 4 2 3 0 15 15 0
00 02 15 14 0 71 0 4 2 3 0 15 15 0
00 02 15 15 0 72 0 4 2 3 0 15 15 0
00 02 15 16 0 73 0 4 2 3 0 15 15 0
00 02 15 17 0 74 0 4 2 3 0 15 15 0
00 02 15 18 0 75 0 4 2 3 0 15 15 0
00 02 15 19 0 77 0 4 2 3 0 15 15 0
00 02 15 24 0 89 0 4 2 3 0 15 15 0
00 02 15 25 0 90 0 4 2 3 0 15 15 0
00 02 15 26 0 91 0 4 2 3 0 15 15 0
00 02 15 27 0 93 0 4 2 3 0 15 15 0
00 02 15 28 0 95 0 4 2 3 0 15 15 0
00 02 15 29 0 96 0 4 2 3 0 15 15 0
............
---------------------------------------------------
For example, for the first three raws:
it should be changed as follows:
00 02 14 19 0 41 0 4 2 3 0 15 15 0
00 02 14 20 0 42 0 4 2 3 0 15 15 0
00 02 14 21 0 43 0 4 2 3 0 15 15 0 ==> inserted line
00 02 14 22 0 44 0 4 2 3 0 15 15 0
=======================================
Thanks in advance!
|
|
|
|
|
If you have many data you could use a linked list structure.
If you want to use arrays, use memmove.
|
|
|
|
|
Thanks!
for example, how to do that?
chen
|
|
|
|
|
There are lots of implementation of linked lists, you could try STL containers, they are very fast if they are used in a good way. There must be examples & tutorials here at CodeProject.
You could also implement it yourself.
Basically it should look like this :
<br />
struct myList {<br />
long somedata;<br />
struct myList *next;<br />
};<br />
"640K ought to be enough for anybody."
Bill Gates
|
|
|
|
|
I am making a little program that recieves ascii commands from the serial port. I want to make the program play an audio file when it recieves a specific string. Does anyone know how to just play an audio file in the background without pulling up windows media player?
Thank you very much.
Mavrock
|
|
|
|
|
http://www.codeproject.com/audio/mp3player.asp[^]
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
u can try with "mciSendString" API function ...
anju
|
|
|
|
|
This should do:
HWND hWnd = MCIWndCreate(GetSafeHwnd(),
AfxGetInstanceHandle(),
MCIWNDF_NOMENU | MCIWNDF_NOPLAYBAR |
MCIWNDF_NOERRORDLG | MCIWNDF_NOOPEN,
szFilename);
MCIWndPlay(hWnd);
To stop playing:
MCIWndStop(hWnd);
MCIWndDestroy(hWnd);
|
|
|
|
|
Hello,
I'm working on WIA and trying to aquire image/audio/video from a digital camera. Everything looks fine like select the device and image. However, I still not problem tranfering file from the camera to the target machine. What I want is transfer the file from the camera to a file in the target, then I would like to get the file name from a STGMEDIUM and move to another location. According to MSDN, I set lpszFileName member of the pMedium structure to NULL to allow WIA to determine the file name and location for the new file. However, pIWiadataTransfer->idtGetData always returns STG_E_MEDIUMFULL and IWiaEventCallback::ImageEventCallback never be called. Do you know why? Thanks!
IWiaDevMgr* g_pIWiaDevMgr = NULL;
if (SUCCEEDED(CoCreateInstance(CLSID_WiaDevMgr, NULL, CLSCTX_LOCAL_SERVER,
IID_IWiaDevMgr, (void**)&g_pIWiaDevMgr)))
{
IWiaItem* pIWiaRootItem = NULL;
if (g_pIWiaDevMgr->SelectDeviceDlg(m_hWnd, StiDeviceTypeDefault, 0, NULL, &pIWiaRootItem) == S_OK)
{
LONG lItemCount = 0;
IWiaItem** ppWiaItem = NULL;
if (pIWiaRootItem->DeviceDlg(m_hWnd, 0, WIA_INTENT_NONE, &lItemCount, &ppWiaItem) == S_OK)
{
CWaiDataCallback* pWaiDataCallback = new CWaiDataCallback;
pWaiDataCallback->AddRef();
for (int i = 0; i < lItemCount; i++)
{
#if 0 // Do I have to setup some parameters for WriteMultiple?
IWiaPropertyStorage* pIWiaPropStg = NULL;
if (SUCCEEDED(ppWiaItem[i]->QueryInterface(IID_IWiaPropertyStorage, (void**)&pIWiaPropStg)))
{
PROPSPEC PropSpec;
PropSpec.ulKind = PRSPEC_PROPID;
PropSpec.propid = WIA_IPA_FORMAT;
PROPVARIANT PropVar;
PropVar.puuid = &WiaImgFmt_BMP;
pIWiaPropStg->WriteMultiple(1, &PropSpec, &PropVar, 2);
pIWiaPropStg->Release();
}
#endif
IWiaDataTransfer* pIWiadataTransfer = NULL;
if (SUCCEEDED(ppWiaItem[i]->QueryInterface(IID_IWiaDataTransfer, (void **)&pIWiadataTransfer)))
{
STGMEDIUM StgMedium = { 0 };
StgMedium.tymed = TYMED_FILE;
if (pIWiadataTransfer->idtGetData(&StgMedium, pWaiDataCallback) == S_OK) // *** Always return STG_E_MEDIUMFULL
{
pIWiadataTransfer->Release();
ReleaseStgMedium(&StgMedium);
}
}
ppWiaItem[i]->Release();
pWaiDataCallback->Release();
}
CoTaskMemFree(ppWiaItem);
}
pIWiaRootItem->Release();
}
g_pIWiaDevMgr->Release();
}
|
|
|
|
|
I dunno, but this months MSDN has a huge story on DirectShow to do exactly this, and it's available online at msdn.microsoft.com
It may be last months now, it's just come out in newsagents in Australia.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
I have emebedded a header control inside my main control but the header flickers madly despite having WS_CLIPCHILDREN specified in the main control. I have tried using SetRedraw() but that didn't work either...
These I figure are my options:
1) I owner draw the header control, but I'd really like to avoind this
2) I use InvalidateRect() somehow inside OnPaint handler of main control and invalidate the client rect - the header control height??? is this a possible solution...?
-----------------
| header control| <-- Ignore this part of client rect using InvalidateRect()...???
-----------------
| main control |
| |
| |
-----------------
Would this solve the header flicker problem...?
I've already double buffered the main control and handled OnEraseBkgnd() of main control properly
Ideas...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
1 possibility springs to mind:
in both your OnPaint() and OnEraseBkgnd() handlers you call ExcludeClipRect() on the device context to clip out the header rect.
|
|
|
|
|
Throughout my code, after creating an application, I see comments in the header files such as:
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_XMAINWINDOW_H__CB25AA97_9522_4128_9EAE_946D14A1C1EB__INCLUDED_)
What purpose do they serve and I am required to keep them there? I'd prefer to remove them to keep my code as clean as possible for my own organization.
Thanks,
-Matt
|
|
|
|
|
There's an option when you start a new project...
"Would you like to generate source file comment?"
Yes, please
No, thank you
Selecting no generates a project without all the of the source code comments like you described...
|
|
|
|
|
Perhaps it's becuz i use learners edition, I can't afford the full package, but even when I select no comments I still get the comments mentioned by the original poster...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I think it only turns off the big comments like the stuff in InitDialog and InitInstance. The small stuff mentioned above is kept, especially the classwizard related stuff.
Michael
Time flies like an arrow. Fruit flies like a banana
|
|
|
|
|
this is part of a header guard. it's a C/C++ trick to prevent a header from being included more than once during a compilation (to avoid multiple declarations). it matches up with the # if!defined and #define stuff at the top of your headers.
don't touch it. these aren't just comments.
-c
For men use, if they have an evil turn, to write it in marble:
and whoso doth us a good turn we write it in dust.
-- Sir Thomas More
|
|
|
|
|
I found this code to create a combobox (to be embedded in a toolbar)
CRect rect;
int nIndex = m_wndToolBar.GetToolBarCtrl().CommandToIndex(ID_COMBO);
m_wndToolBar.SetButtonInfo(nIndex, ID_COMBO, TBBS_SEPARATOR, 205);
m_wndToolBar.GetToolBarCtrl().GetItemRect(nIndex, &rect);
rect.top = 1;
rect.bottom = rect.top + 250 ;
if(!m_comboBox.Create(CBS_DROPDOWNLIST | CBS_SORT | WS_VISIBLE |
WS_TABSTOP | WS_VSCROLL, rect, &m_wndToolBar, ID_COMBO))
{
TRACE(_T("Failed to create combo-box\n"));
return FALSE;
}
I need an editbox, not a combobox. How do I modify this code ? Also, if I want to write stuff to this cEdit , how do I do that? Theres no m_Edit variable as I would have if it were on a form by itself, to do setwindowtext.
Thanks,
|
|
|
|
|
Actually I see that there will be an m_Edit variable so I suppose I can do a SetWindowText.
|
|
|
|
|
You'd change the first parameter to reflect the flags you wanted to apply to the edit box. They are listed in MSDN. The WS_ flags are generic and would remain.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
i use c++ to communicate with a java app through pipe (simply u can think the java app is javac.exe).
when the java app writes data to pipe (std io), i read data by c++ (Windows-not dos or unix).
with java 1.4, there is no any problem. but for jdk 1.3 or 1.2, i have trouble:
if the java app exits with no suitable signal, c++ doesn't know (if jdk 1.4, c++ knows) and is still waiting there.
i think there must be some idea to know because another side of pipe is closed.
key functions used are:
CreatePipe, CreateProcess, ReadFile.
i think ReadFileEx should be better but i got no idea about it after testing.
thx for ur suggestion.
;);P ((
includeh10
|
|
|
|
|
Are you calling CloseHandle on the pipe handles when you are done with them? This should signal to either the Write or the Read side that the pipe has been closed/broken and you can cleanup/exit.
i.e.:
DWORD dwBytesToRead = 0;
<P></P>
BOOL bStatus = ReadFile( m_hReadPipe, &SomeData, dwBytesToRead, &dwBytesRead, NULL );
<P></P>
if( bStatus && (dwBytesRead > 0) )
{
<P></P>
CloseHandle(m_hReadPipe);
m_hReadPipe = INVALID_HANDLE_VALUE;
}
else
{
if( m_hReadPipe != INVALID_HANDLE_VALUE)
{
CloseHandle(m_hReadPipe);
m_hReadPipe = INVALID_HANDLE_VALUE;
}
}
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
I had similar problems with a C++ client. The read did not always
give the right error codes to see if the conn was broken.
I used named pipes and there is a very handy function named
PeekNamedPipe
if PeekNamedPipe returns an error, You can be sure that the conn is lost.
If no data is pending, nothing happens.
|
|
|
|
|
I am having some problems on VS.Net
I've just created a popup menu with some IDs (ID__LAUNCHEXPLORER, ID_CLOSEAPP) in the resource editor.
Within VS.Net development environment, I go to the properties page and select 'Menu Commands' then expand the listbox that has ID__LAUNCHEXPLORER so it has the COMMAND field visible. When I then click on the combo box dropdown list and click on 'add' the following error message occurs: "Add/Remove of the function is impossible, because the parent class code is read only"
I can (and did) add the functions manually and type in the mapping through the message map manually too (which works) but I haven't a clue why VS.net's doing this?
Anyone any ideas? Bring back ClassWizard! VS.Net seems to want so many windows open at once I might be persuaded to buy a 24" monitor or something just so I can see the postage stamp that's left for my code!
see ya
Adam.
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|