|
Hello
I kindly ask for a source-code in vc++ to snapshot from a webcam to a bitmap (Graphics::TBitmap).
-- modified at 6:26 Friday 30th June, 2006
|
|
|
|
|
Hi
I have read a lot of articles and researched on internet but I haven't found a way to get HomeTelephoneNumber from WAB. I can get DISPLAY_NAME and EMAIL_ADDRESS but not PR_PRIMARY_TELEPHONE_NUMBER_A
This is the code
<br />
int main(int argc, char* argv[])<br />
{<br />
HINSTANCE hinstWAB=NULL;<br />
HRESULT hr=E_FAIL;<br />
<br />
HKEY keyResult;<br />
BYTE keyValue[MAX_PATH];<br />
DWORD dataout=800;<br />
char PathToWAB[255];<br />
<br />
RegOpenKeyEx(HKEY_LOCAL_MACHINE, WAB_DLL_PATH_KEY, 0, KEY_ALL_ACCESS, &keyResult);
long result = RegQueryValueEx(keyResult, "", 0, 0, keyValue, &dataout);<br />
RegCloseKey(keyResult);<br />
<br />
strcpy(PathToWAB, (char*)keyValue);<br />
<br />
HMODULE hModule = LoadLibrary(PathToWAB);<br />
<br />
if (hModule!=NULL)<br />
{<br />
ssWABOpen = (fWABOpen)GetProcAddress(hModule, "WABOpen");<br />
if (ssWABOpen == NULL) return 2;<br />
HRESULT hr = (ssWABOpen)(&lpAddrBook, &lpWABObject, NULL, 0);<br />
}<br />
<br />
<br />
hr = E_FAIL;<br />
<br />
if (ssWABOpen==NULL) return 1;
{<br />
ULONG lpcbEntryID;<br />
ENTRYID* lpEntryID;<br />
<br />
hr = lpAddrBook->GetPAB(&lpcbEntryID, &lpEntryID);<br />
if (hr!=S_OK) return 10;
<br />
ULONG ulFlags = MAPI_BEST_ACCESS,<br />
ulObjType = NULL;<br />
LPUNKNOWN lpIUnknown = NULL;<br />
hr = lpAddrBook->OpenEntry(lpcbEntryID,<br />
lpEntryID,<br />
NULL,<br />
ulFlags,<br />
&ulObjType,<br />
&lpIUnknown);<br />
<br />
ulFlags = NULL;
<br />
if (ulObjType==MAPI_ABCONT)
{<br />
IABContainer* lpABContainer = static_cast<IABContainer*>(lpIUnknown);
LPMAPITABLE lpMAPItbl = NULL;<br />
hr = lpABContainer->GetContentsTable(ulFlags, &lpMAPItbl);<br />
if(!lpMAPItbl)<br />
{<br />
printf("Error in lpMAPItbl\n");<br />
return 0;<br />
}<br />
<br />
SPropTagArray *propTag;<br />
hr = lpMAPItbl->QueryColumns(TBL_ALL_COLUMNS,(LPSPropTagArray*)&propTag);<br />
<br />
for(int j=0;j<propTag->cValues;j++)<br />
{<br />
<br />
printf("(%d)\n",propTag->aulPropTag[j]);<br />
}<br />
ULONG ulRows;
hr = lpMAPItbl->GetRowCount(0, &ulRows);<br />
if (hr!=S_OK) return 11;
<br />
SRowSet* lpRowSet;<br />
hr = lpMAPItbl->QueryRows(
ulRows,<br />
0,<br />
&lpRowSet);<br />
<br />
<br />
for (ULONG x = 0; x < lpRowSet->cRows; x++) <br />
{<br />
EMAILS thisAddr; <br />
memset(&thisAddr,0,sizeof(thisAddr));<br />
SRow* lpRow = &lpRowSet->aRow[x];
for (ULONG y = 0; y < lpRow->cValues; y++)<br />
{<br />
SPropValue* lPropVal = &lpRow->lpProps[y];<br />
lPropVal->Value.lpszA;<br />
ADRLIST adrl;<br />
adrl.cEntries = 1;<br />
adrl.aEntries[0].cValues = lpRow->cValues;<br />
adrl.aEntries[0].rgPropVals = lPropVal;<br />
<br />
SPropTagArray propTag;<br />
propTag.cValues = 1;<br />
propTag.aulPropTag[0] = PR_HOME_TELEPHONE_NUMBER_A;<br />
<br />
printf("(%x)",lPropVal->ulPropTag);<br />
switch (lPropVal->ulPropTag)<br />
{<br />
case PR_DISPLAY_NAME_A: <br />
strncpy(thisAddr.DisplayName,lPropVal->Value.lpszA,sizeof(thisAddr.DisplayName));<br />
break;<br />
<br />
case PR_ADDRTYPE_A: <br />
strncpy(thisAddr.EmailAddr,lPropVal->Value.lpszA,sizeof(thisAddr.EmailAddr));<br />
break;<br />
<br />
case PR_PRIMARY_TELEPHONE_NUMBER_A:<br />
strncpy(thisAddr.NickName,lPropVal->Value.lpszA,sizeof(thisAddr.NickName));<br />
break;<br />
<br />
default:<br />
break;<br />
}<br />
<br />
}
printf("%s\t%s\t%s\n",thisAddr.DisplayName,thisAddr.EmailAddr,thisAddr.NickName);<br />
<br />
lpWABObject->FreeBuffer(lpRow);<br />
<br />
}
lpWABObject->FreeBuffer(lpRowSet);<br />
}<br />
}<br />
<br />
<br />
<br />
FreeLibrary(hModule);<br />
return 0;<br />
}<br />
Thanks in advance.
-----------------------------
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Hi
I got it solved. It was simple, but having no previous experience in MAPI gives headache.
Used this code before QueryRows.
<br />
SizedSPropTagArray(5,propArray) = {5, {PR_ENTRYID,PR_OFFICE_TELEPHONE_NUMBER,PR_BUSINESS_TELEPHONE_NUMBER,PR_HOME_TELEPHONE_NUMBER,PR_DISPLAY_NAME} };<br />
hr=lpMAPItbl->SetColumns((SPropTagArray*)&propArray,ulFlags);<br />
-----------------------------
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Hi
I have a theoritical doubt in c/c++, that at the end of some functions I am seeing a const keyword. I dont know what is the purpose behind this.
for example
int function(int funcpar1,int funcpar2)const;
I want to know purpose of the const keyword at the end
Thanks
|
|
|
|
|
|
This means that the function does not modify data members of the class and does not call other functions which are not marked as const .
Functions that just read and return information must be made const . Otherwise the following sample will not work:
const CMyString s = "Test";
int length = s.GetLength();
This is because the s variable was declared as constant, se we cannot modify it.
-- modified at 6:33 Friday 30th June, 2006
|
|
|
|
|
In those const functions, we could not change an object's state (be more specific member variables value)
examples are some "Get" interfaces, those function's (most probably) are not supposed to change it's object state, it is for returning something that belong to the object.
Putting const at end of function meaningfully is a good practice.
SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."
My Blog | Understanding State Pattern in C++
|
|
|
|
|
If someone know this,please help me!
request:I want to intercept screen by my will.For example I intercept intercept an area,and then save it as a bitmap or jpg.
Could you send your help to my Email mathematicianzhixin@126.com
Thanks for everyone.
|
|
|
|
|
http://www.codeproject.com/bitmap/BitmapFromScreen.asp
|
|
|
|
|
See if this helps.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi..
How can we replace a line in a .TXT file using C++??
My aim is to replace a particular line in a ABC.TXT with another line from a ZYWV.TXT file??
Plz HELP ME!!
Thanks.
|
|
|
|
|
User fscanf/fread to scan through the file and go to the required line
Once the required line is found, use fseek to go back to the start of the line
Do a fprintf/fwrite again.
Keep in mind that if the new line is longer that the line in the file, it will overwrite entries in the next line. You will have to devise a appropriate insertion/modify strategy if the line lengths can be different.
|
|
|
|
|
From ABC.TXT, write all lines up to the line to be replaced into a temporary file. Write the new line into the temporary file. Write the remaining lines from ABC.TXT into the temporary file. Delete ABC.TXT. Rename the temporary file to ABC.TXT. Make sense?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Try something like this (haven't tested this).
----------------------------------------------
#incluce <iostream>
#include <fstream>
#include <string>
int main(int argc, char* argv[])
{
using namespace std;
// Open files.
ifstream inf("C:\\in.txt");
if (!inf)
{
cerr << "Failed to open input file" << endl;
return 1;
}
ofstream outf("C:\\out.txt");
if (!outf)
{
cerr << "Failed to open output file" << endl;
return 1;
}
// Copy the input file to the output file line by line replacing as needed.
string line;
while (getline(inf, line))
{
if (line=="Replace this line")
{
outf << "With this line" << endl;
}
else
{
outf << line << endl;
}
}
return 0;
}
Steve
|
|
|
|
|
I need to intercept the GDI ::GetPixel() API. I need to get the screen coordinates before GDI can do it's default processing. I need this capability on Win98/ME/2000/XP. Here is what I have found out so far -
1. The SetDDIHook API seems to be gone. Not sure if it is still available to program as part of VS 6.0 headers/libraries. The API documentation mentions something about 16 bit DLLs, so again not sure if it applies to the 32 bit OSs that I am interested in.
2. Would writing a filter video driver do the job? If so, where would I get the IOCTL codes for GetPixel that needs to be intercepted? I assume there is some IOCTL code for GetPixel which the display video driver would look at.
-- modified at 1:16 Monday 3rd July, 2006
|
|
|
|
|
The dialog window can be resize and it max is full screen. how to fix the min size of the dialog??? Thx.
|
|
|
|
|
Handle 'WM_GETMINMAXINFO' message:
void CMyWindow::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
lpMMI->ptMinTrackSize.x = 200;
lpMMI->ptMinTrackSize.y = 150;
}
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
thz x 100000000000000000000000
|
|
|
|
|
It seems you have to handle the WM_GETMINMAXINFO notification sent to your dialog.
|
|
|
|
|
thx a lot
|
|
|
|
|
<pre>CMixer::CMixer(DWORD ComponentType, DestKind dkKind): m_dwControlID(-1), m_bOK(false), m_dwChannels(0)
{
HMIXER hMixer;
HRESULT hr;
hr = mixerOpen(&hMixer, 0, 0, 0,0);
if (FAILED(hr)) return;
MIXERLINE mxl;
MIXERCONTROL mc;
MIXERLINECONTROLS mxlc;
DWORD kind, count;
if (dkKind == Play)
kind = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
else
kind = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = kind;
hr = mixerGetLineInfo((HMIXEROBJ)hMixer, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);
if (FAILED(hr))
{
mixerClose(hMixer);
return;
}
count = mxl.dwSource;
for(UINT i = 0; i < count; i++)
{
mxl.dwSource = i;
mixerGetLineInfo((HMIXEROBJ)hMixer, &mxl, MIXER_GETLINEINFOF_SOURCE);
if (mxl.dwComponentType == ComponentType)
{
m_dwChannels = mxl.cChannels;
mc.cbStruct = sizeof(mc);
mxlc.cbStruct = sizeof(mxlc);
mxlc.dwLineID = mxl.dwLineID;
mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
mxlc.cControls = 1;
mxlc.cbmxctrl = sizeof(MIXERCONTROL);
mxlc.pamxctrl = &mc;
hr = mixerGetLineControls((HMIXEROBJ)hMixer, &mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
m_dwControlID = mc.dwControlID;
break;
};
}
mixerClose(hMixer);
m_bOK = true;
}</pre>
Could anyone please let me know why is this code not controlling the play volume even if MIXERLINE_COMPONENTTYPE_DST_HEADPHONES,play are passed as parameter to CMixer class. The above code is controlling the record volume perfectly.
Indu
|
|
|
|
|
I have an application that uses a CMyHTMLView derived from CHtmlView. The user can have multiple CHtmlViews open at the same time. Everything seems to work fine until we try to Serialize. In Serialize each CHtmlView gets the HTML from the browser to save by doing this:
MSHTML::IHTMLDocument2Ptr doc = GetHtmlDocument();
IPersistStreamInitPtr stream = doc;
CStreamOnCString sstream;
stream->Save( static_cast<istream*>(&sstream), false );
CString result;
VERIFY(sstream.CopyData( result ));
sstream.Release ();
stream.Release ();
doc.Release ();
The problem is every CHtmlView returns the same HTML as is in the most recently opened CHtmlView, even if they're in different documents. I tried using different methods to get the source (including CHtmlView::GetSource, which doesn't always give me all the HTML) but they all do the same thing.
Then it occurred to me that maybe they all have the same HTML in them, so in my app I used the context menu's view source to check and, sure enough, they all show the same code. If I go to one of the earlier opened views and Refresh, it updates to display the same thing as the most recently opened view.
The views are being controlled from VBScript using an IWebBrowser2 passed by my app, which I get by:
GetApplication ()->QueryInterface (__uuidof(IWebBrowser2),(void**) (&pNewBrowser));
and are usually displaying files from the local machine.
Views are created using CreateView from Stingray's CGXTabWnd, which seems to call CRuntimeClass::CreateObject. The CMyHTMLViewclass does IMPLEMENT_SERIAL but not DECLARE_DYNCREATE.
When, from VBScript, we call Navigate to load pages in, it does display the correct page and doesn't visually modify any other existing browser.
Any idea what I'm doing wrong?
-- modified at 4:45 Friday 30th June, 2006
|
|
|
|
|
The problem is difficult to reproduce.
What happens if you comment some parts of serialization function?
|
|
|
|
|
*Sigh* As usual, I assumed the problem ran deeper than it did. My assumption that my routine to get the HTML from the browser was actually doing that seems to be wrong. It was getting it from, in my case, the file the browser had navigated to.
That is, if I loaded a file in the browser and then deleted the file and tried my GetSource function it wouldn't work...
It's hard work being an idiot.
|
|
|
|
|
Hi,
What API can I use to play a simple avi-file on the window (HWND)?
Please not using DirectX (DirectShow).
thanks in advance,
Ward
Ward
|
|
|
|
|