|
You can also fill in a SystemTime structure, and then call SystemTimeToFileTime, and then CompareFileTime.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi there,
I have a DLL (DLL_1)for some measurement instrument that exports some functions, when I load DLL_1 from an MFC application and call Function_1 everything goes fine, but this not the way I want to use DLL_1. What I am trying to do is to create another DLL (DLL_2) to load the DLL_1 and call Function_1 but this always fails with a memory read error saying something like: "the memory at address 0x5435345 could not be read", this is wiered coz it is exactly the same code on the same machine.
btw: Function_1 has one integer parameter so I don't think it has anything to do with passing parameters to the function!
Could this have anything with the way DLLs manage memory? Any help? Any ideas?
Thanks alot
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
Did you try to use your debugger to retrieve more information about the problem ?
|
|
|
|
|
Hi,
Unfortunately I have the DLL as release mode executable with no debugging information at all! the only thing the debugger will be able to display is some assembly code along with memory addresses which are not likely to be of much use, if you think that I can use them in someway plz let me know.
btw: the function call (that craches when is made from a DLL) is so simple that it goes like this:
int res = MyFunction(4);
Cheers
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
Are you allocating/unallocating memory? If the answer is yes, see, for instance [^], <[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
No, I am not allocating any memory in my own code, I only call one function like this:
int res = MyFunction(5);
that's all I do.
Thanks for the reply
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
I Want to Create process on Remote computer.But, I Invoke GetObject() failed with message:"Access Denied" .thanks.
The code:
HRESULT hres;
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
TRACE("Failed to initialize COM library. Error code = %ld",hres);
return;
}
if(S_OK!= CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, 0) )
{
TRACE("Failed to initialize security. Error code = %ld\n",hres);
CoUninitialize();
return;
}
IWbemLocator *pLoc = NULL;
hres = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hres))
{
TRACE("Failed to create IWbemLocator object.Err code = %ld\n",hres);
CoUninitialize();
return;
}
IWbemServices *pSvc = NULL;
hres = pLoc->ConnectServer(
_bstr_t(L"\\\\192.168.0.2\\ROOT\\CIMV2"),
_bstr_t("administrator"),
_bstr_t("2007"),
NULL,
NULL,
NULL,
0,
&pSvc
);
if (FAILED(hres))
{
TRACE("Could not connect. Error code = %ld\n",hres);
pLoc->Release();
CoUninitialize();
return;
}
TRACE("Connected to ROOT\\CIMV2 WMI namespace\n");
hres = CoSetProxyBlanket(
pSvc,
RPC_C_AUTHN_WINNT,
RPC_C_AUTHZ_NONE,
NULL,
RPC_C_AUTHN_LEVEL_CALL,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE
);
if (FAILED(hres))
{
TRACE("Could not set proxy blanket. Error code = %ld\n",hres);
pSvc->Release();
pLoc->Release();
CoUninitialize();
return;
}
BSTR MethodName = SysAllocString(L"Create");
BSTR ClassName = SysAllocString(L"Win32_Process");
IWbemClassObject* pClass = NULL;
[color=#FF0000] hres = pSvc->GetObject(ClassName, 0, NULL, &pClass, NULL);[/color]
if (FAILED(hres))
{
TRACE("Could not GetObject. Error code = %ld\n",hres);
SysFreeString(ClassName);
SysFreeString(MethodName);
pSvc->Release();
pLoc->Release();
CoUninitialize();
return;
}
IWbemClassObject* pInParamsDefinition = NULL;
hres = pClass->GetMethod(MethodName, 0, &pInParamsDefinition, NULL);
IWbemClassObject* pClassInstance = NULL;
hres = pInParamsDefinition->SpawnInstance(0, &pClassInstance);
VARIANT varCommand;
varCommand.vt = VT_BSTR;
varCommand.bstrVal = L"\\\\192.168.2.2\\Setup\\IntraView.exe";
hres = pClassInstance->Put(L"CommandLine", 0,
&varCommand, 0);
if (FAILED(hres))
{
TRACE("Could not put. Error code = %ld\n",hres);
SysFreeString(ClassName);
SysFreeString(MethodName);
pClass->Release();
pSvc->Release();
pLoc->Release();
CoUninitialize();
return;
}
IWbemClassObject* pOutParams = NULL;
hres = pSvc->ExecMethod(ClassName, MethodName, 0,NULL, pClassInstance, &pOutParams, NULL);
if (FAILED(hres))
{
TRACE("Could not execute method. Error code = %ld\n",hres);
SysFreeString(ClassName);
SysFreeString(MethodName);
pClass->Release();
pInParamsDefinition->Release();
pOutParams->Release();
pSvc->Release();
pLoc->Release();
CoUninitialize();
return;
}
SysFreeString(ClassName);
SysFreeString(MethodName);
pClass->Release();
pInParamsDefinition->Release();
pOutParams->Release();
pLoc->Release();
pSvc->Release();
CoUninitialize();
|
|
|
|
|
It's been quite awhile since I coded this kind of thing, but, as I recall, the call to make once you have retrieved the IWbemServices pointer from IWbemLocator::ConnectServer is, IWbemServices::ExecQuery[^]. Are you getting WBEM_E_ACCESS_DENIED from GetObject? If so, you will probably get the same thing from IWbemServices::ExecQuery.
|
|
|
|
|
You are Right.I Try To Invoke ExecQuery ,but return the same message"Access Denied".
Are you once Remote Invoke the wmi
|
|
|
|
|
Hello All
I am tring to getpath of shortcut.I can do it for normal shortcut but in case of internet Explorer shortcut I am unable to find out path and icon.
i am using IShellLink .GetPath(...);
plz help me for internet explorer.
|
|
|
|
|
You can see the installed browsers on a 32 bit machine under following path
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\
you can fine fine the the path of internet explorer at following key
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\IEXPLORE.EXE\shell\open\command
the Icon will be embedded in the exe itself.
the index of the icon is available at
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\IEXPLORE.EXE\DefaultIcon
You can ExtractIcon or similar APIs to get the icon from executable.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Thanks Sarath.
But i want programatically bye IShell.GetPath( is this not possilbe..?
|
|
|
|
|
in my project there is a function called ExportandZip().it is working normally in debug mode.but in relese mode it is giving an error saying that "there is no source line for debugging information"what might be the reason.please let me know?
kir_MFC
|
|
|
|
|
|
See Debugging Release Mode Problems[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Sounds like the .pdb file is out of synch. Are you really wanting to debug in release mode? Can you delete the .pdb file and rebuild your project?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hai!
I am taking a image from a location, converting into byte array and displaying it back on my dialog by converting into bitmap image!
HBITMAP hBitMap;
hBitMap = (HBITMAP) LoadImage (NULL, \
"c:\\Documents and Settings\\Desktop\\Image\\bitmap1.bmp", \
IMAGE_BITMAP, SM_CXICON, SM_CYICON, LR_LOADFROMFILE);
CBitmap bmp;
bmp.Attach((HBITMAP)hBitMap); // handle I got from LoadBitmap
BITMAP bitmap;
bmp.GetBitmap(&bitmap);
int size = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8;
BYTE *lpBits = new BYTE [ size ];
// Here i convert the image to byte array
::GetBitmapBits((HBITMAP)hBitMap,size,lpBits );
// Here i get the handle to the picture control on my dialog
HWND hImage = this->GetDlgItem(IDC_STATIC_IMAGE)->GetSafeHwnd();
// I Call the following function to paint the converted byte array
SetRawBitsToImage (hImage,bitmap.bmWidth,bitmap.bmHeight,lpBits ,32);
//The defination of the above function is
// hwnd = handle to the image control
// W = width of the raw bits Image
// H = height of the raw bits Image
// lpBits = pointer to the raw bits image
// BitCount = 32,24 etc ( depend on the bit count ) defualt =32
void CMyTryImageDlg:: SetRawBitsToImage (HWND hwnd,int W,int H,BYTE *lpBits, int BitCount)
{
HDC hDC = ::GetDC(hwnd);
::SetWindowPos(hwnd,0,0,0,W,H,SWP_NOMOVE);
BITMAPINFO bi;
memset(&bi,0,sizeof(BITMAPINFO));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = W;
bi.bmiHeader.biHeight = H;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = BitCount;
bi.bmiHeader.biCompression = BI_RGB;
bi.bmiHeader.biSizeImage = bi.bmiHeader.biWidth*bi.bmiHeader.biHeight*BitCount/8;
::SetDIBitsToDevice(hDC,
0,0,
W,
H,
0,
0,
0,bi.bmiHeader.biHeight,
&lpBits,&bi,DIB_RGB_COLORS);
::ReleaseDC(hwnd,hDC);
}
// But nothing is getting displayed? why? Is there any mistake in code?
// I donot have knowledge in images
Thanks!
|
|
|
|
|
Where exactly does it seem to fail, did you try stepping thorough the code with the debugger to see what happens?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Yes,
Actually inside SetRawBitsToImage (), there is SetDIBitsToDevice (), it must return no of rows scanned, but it returns zero, I tried with GetLastError (), but it returns zero, stating no error, i tried while debuggging to see the value od hdc , it stated "Unused:Expression cannot be solved"!!
Thanks!
|
|
|
|
|
I tried to run your code and see what happens (in a completely new dialog-based project) but for some reason if i try to load a bitmap either from resource or from file with LoadImage or LoadBitmap i get back NULL and zero for GetLastError or either "the parameter is incorrect" or "there is not enough storage to execute the requested command" (not literally quoted)... so anyways, you know you might get negative heights for a bitmap if it is stored upside-down, this nice feature can make one's life ...less enjoyable... so maybe try checking out the heights...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Why the flip do that at all? You've loaded the image into a bitmap - why not just display that with BitBlt[^] or StretchBlt[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Actually this is a sample to check "How to display image from an byte array?"
In my actual requirement, I will be having an byte array, i have to display image from it?
I was just trying withe the function , but nothing gets displayed !!
Any other simple technique to display Byte Array to image on my dialog box !!
Please its very urgent!!
thanks !
|
|
|
|
|
You code doesn't make sense.
As I said again and again you should at least know how the image data is stored in your buffer before even attempting to display it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
hello,
After i build my project and run it i get the following error :
Debug assertion failed
Program: C:\Documents and Settings\tasmin\Desktop\Ref Projects\FINAL CBIR\NggolekiGinambaran\Debug\NggolekiGinambaran.exe
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\appcore.cpp
line: 380
i don have a "f" drive in my system. i'm not able to understand wat this means and refers to.
please help.....
tasmin
|
|
|
|
|