|
w_logan wrote:
(*pVal)->AddRef();
Please confirm that before the above selected code
pVal != NULL
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I need to copy data using com from one application to another.For example if card inserted in the card reader it takes the data from card and place it at the position of the cursor of the currently running application. My code to control card will be in c++ or java or vb but i want to use com to do data transfer like barcode reader driver does.
|
|
|
|
|
You can do it with SetWindowText API function. You should pass the handle of the edit you want to insert data.
It works fine!
You can also use SendMessage API.
If you have questions about using them, please ask.
|
|
|
|
|
Thanks but I don't know how to use both SetWindowText API and SendMessage API, I expect another help from you
|
|
|
|
|
Also I want to pass the handle of any edit which currently has focus.
|
|
|
|
|
Hi
Get the handle of the window that currently has focus, using GetForegroundWindow() API.
Then Find the Edit inside the window using FindWindowEx function. Which returns the window handle for the edit box.
After that, you set the text as follows:
SetWindowText(EditHandle, "ANYTHING YOU WHICH")
For help under any of these APIs please refere to MSDN.
|
|
|
|
|
Hi all,
I look for common class name for all editable control running on windows OS
|
|
|
|
|
Hi all
I am using WMI(Windows Management Instrumentation) to extract varios system information, here when it returns VT_NULL, and I try to assign this variant type variable to a structure then memory access violation error appears.
The code snippet is as follows:
IEnumWbemClassObject * pEnumObjectStorageDevice = NULL;
HRESULT hResStorageDevice;
BSTR strQueryStorageDevice = (L"Select * from Win32_LogicalDisk");
BSTR strQLStorageDevice = (L"WQL");
hResStorageDevice = pWbemServices->ExecQuery(strQLStorageDevice, strQueryStorageDevice,WBEM_FLAG_RETURN_IMMEDIATELY,NULL,&pEnumObjectStorageDevice);
if(hResStorageDevice != S_OK)
{
MessageBox("Could not execute Query");
return;
}
ULONG uCountStorageDevice = 20, uReturnedStorageDevice;
IWbemClassObject* pClassObjectStorageDevice;//[20]; // = NULL;
i=0;
while (pEnumObjectStorageDevice)
{
HRESULT hr = pEnumObjectStorageDevice->Next(WBEM_INFINITE, 1,&pClassObjectStorageDevice, &uReturnedStorageDevice);
int a = GetLastError( );
if(uReturnedStorageDevice == 0)
{
break;
}
VARIANT vStorageDeviceDriveLetter,vStorageDeviceDriveType,vFileSystem;
VARIANT vDriveSize,vFreeSpace;
BSTR strClassPropStorageDevice = SysAllocString(L"Caption");
hr = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, &vStorageDeviceDriveLetter, 0, 0);
strClassPropStorageDevice = SysAllocString(L"Description");
hr = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, &vStorageDeviceDriveType, 0, 0);
strClassPropStorageDevice = SysAllocString(L"FileSystem");
HRESULT hrFileSystem = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, (&vFileSystem), 0, 0);
strClassPropStorageDevice = SysAllocString(L"Size");
hr = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, (&vDriveSize), 0, 0);
strClassPropStorageDevice = SysAllocString(L"FreeSpace");
hr = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, (&vFreeSpace), 0, 0);
StructStorageDeviceInfo[i].strDriveLetter = vStorageDeviceDriveLetter;
StructStorageDeviceInfo[i].strDriveType = vStorageDeviceDriveType;
StructStorageDeviceInfo[i].strDriveFileSystem = vFileSystem;
StructStorageDeviceInfo[i].strDriveSize = vDriveSize;
i++;
VariantClear(&vStorageDeviceDriveLetter);
VariantClear(&vStorageDeviceDriveType);
VariantClear(&vFileSystem);
VariantClear(&vDriveSize);
VariantClear(&vFreeSpace);
}
Here when this program enumerate A: and there is no disk in FDD, then in case of "File System, Drive Size & Free Space" it returns VT_NULL and in line
StructStorageDeviceInfo[i].strDriveFileSystem = vFileSystem;
Memory access violation error appears .
Please suggest me to overcomr this problem.
Thanks & Regards.
Edit/Delete Message
|
|
|
|
|
Rajiv,
In your structure member what is the type of strDriveFileSystem. And also it is not a good practise to assign a VARIANT structure data to the structure member..
1. First Clear the variant variable
2. if strDriveFileSystem is just a pointer to a char array, there should not be any access violation. I think strDriveFileSystem should a class variable which is trying to convert the variant value to a string thus a exception..
if the strDriveFileSystem is valid,
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Rajiv,
In your structure member what is the type of strDriveFileSystem. And also it is not a good practise to assign a VARIANT structure data to the structure member..
1. First Clear the variant variable
2. if strDriveFileSystem is just a pointer to a char array, there should not be any access violation. I think strDriveFileSystem should a class variable which is trying to convert the variant value to a string thus a exception..
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Hi there!
I have a component that registers an Event Sink i Exchange 2000. All was fine and dandy until I - for other reasons - had to reinstall my component.
Now when I try to register my Event Sink in the SystemMailBox through ADODB I get an "Access denied" error. I have already searched high and low on Google - but can only find other people with the same problem, but no solution.
The problem occurs when I set the field "DAV:contentclass" to "storeeventreg".
Does anybody have a solution to this problem ?
Best regards,
Michael B. Hansen
|
|
|
|
|
Hi!
i am facing problem with COM+ service to print doc when COM+ Service owner is not logged on the system.As this service uses user profile to load list of printers to select one that is specified in configuraion or any other.Problem is that if user profile is only available when user logs on to system.currently i am using a utility to restart com+ service after user logs on to get printer list.
Any solution to this issue.
Regards,
=-=-=-=-=-=-=-=-=-=
Anayet
=-=-=-=-=-=-=-=-=-=
|
|
|
|
|
Hi,
Can someone tell me what is the difference between compiling in the following mode??
Win32 Release MinSize
Win32 Release MinDependency
Win32 Unicode Release MinSize
Win32 Unicode Release MinDependency
Thanks in advance
|
|
|
|
|
They are all different;
Win32 vs Win32 Unicode
The code is built with either _UNICODE and UNICODE defined (the latter), or not (the former), which generally means using wide versions of system APIs, etc, except where explicit calls are made. Unicode apps won't run on W9x/ME systems, unless you're also using the MSLU.
MinSize and Mindependency will also alter the way it's compiled. Mindependency means it relies on almost nothing else at install/runtime, so will often cause non-dll versions of libraries to be linked in, which may result in a larger app and a bigger footprint. Minsize does the reverse, and will use DLL versions of things like the CRT, which will give you a smaller app, and for apps that use DLL components which also use DLL versions of libraries, a smaller footprint. This is somewhat simplified.
Steve S
Developer for hire!
|
|
|
|
|
Thanks for the reply. One of the few good reply I had read.
There are too many replies in this forum that never asks the questions.
|
|
|
|
|
I am trying to get an array created in a COM Server and passed back to the client by the mechanism: [out, size_is(,*pNum_ROI_nodes)] float **pROI_coords
from the .idl file.
Where the pNum_ROI_nodes is the size of the array and pROI_coords is the name of the array.
Problem: I am receiving only one value back in this array on the client side. I have verified that only one value is being allocated in the array by the marshaller in the client side. All data is being loaded into the server side of this array (where it is being created by (float*) CoTaskMemAlloc((resultNodes * 2) * sizeof(float))) The data on the client side is the very first value loaded into it by the server and nothing else except 0x0d f0 ad ba in the second location. (bad food)
Is there some setting for the COM that is confusing the marshaller? The above [out, size_is(,*pNum_ROI_nodes)] float **pROI_coords is only in the *.idl file. Should it be somewhere else as well??
The marshaller just doesn't seem to be getting the idea that there is an array, rather a single value.
Thanks in advance,
David
|
|
|
|
|
The standard TypeLib marshaller knows nothing about [size_is] keyword for parameter and cannot be used here. Instead you should build the Proxy/Stub DLL and use it to marshal this interface.
With best wishes,
Vita
|
|
|
|
|
Thank you for your posting, but I need some more info on how to do what you suggested. Could you tell me some steps on how to do this and how is it different than what I have already done? I don't know the difference.
Regards,
David
|
|
|
|
|
Look at main cpp file. Here you can find the useful information. Something like that:
// XXXX.cpp : Implementation of WinMain or DLL Exports.
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f XXXXps.mk in the project directory.
With best wishes,
Vita
|
|
|
|
|
I tried to do that from a command prompt window, but got an error:
fatal error C1189: You need a Windows2000 or later to run this stub because it uses the following features: NMAKE: error U1077: 'cl' return code '0x2'. Stop.
Any ideas?
David
|
|
|
|
|
I don't know what should you do in this case. I didn't use the command prompt window.
1. You can create (and add to existing DSW) the new project which will produce the Proxy DLL. The type of this project is "Makefile" selected from all available projects.
2a. You can add the xxxps.mk file into "Source" files of your project and specify the "Custom Build" for this entry.
2b. You can specify the "Custom Build" (or "Post-biuld step") for your project entry to make and register the Proxy DLL.
IOW, let the VC IDE to run NMAKE into correct environment formed by IDE.
With best wishes,
Vita
|
|
|
|
|
Hi Vita,
I can see you are good with COM and C#. I am new to use c# and I did not use COM before. I would appreciate if you could help me.
I need to execute Cache methods from c# programm. Now Cache does not have yet any interface to c#, but there is COM for c++ 6.
Using this COM in c# I can open Cache DB, but I cannot (I do not know how) to access properties of the classes stored in Cache database.
I exported Cache classes in ODL format. Cache created this file that has uuid and id for every method I created in Cache. Now, my problem is how can I call these methods in C#? I would appreciate if you could refere where can I find any code how to call methods when I have them in odl file.
Thanks in advance,
RikaBoy
-- modified at 3:46 Saturday 27th August, 2005
|
|
|
|
|
|
Hello David,
I assume that you have declared your array-returning method similar to the following :
[helpstring("method GetFloatArray01")] HRESULT GetFloatArray01([out] LONG* pNum_ROI_nodes, [out, size_is(,*pNum_ROI_nodes)] FLOAT** pROI_coords);
Now, in your code for the server which implements this method, did you assign a proper value for "pNum_ROI_nodes" ?
I created a sample implementation as follows :
STDMETHOD(GetFloatArray01)
(long * pNum_ROI_nodes, float * * pROI_coords)
{
long resultNodes = 5;
*pNum_ROI_nodes = resultNodes * 2; // <-- important.
*pROI_coords = (float*)CoTaskMemAlloc((resultNodes * 2) * sizeof(float));
(*pROI_coords)[0] = 1.0;
(*pROI_coords)[1] = 2.0;
(*pROI_coords)[2] = 3.0;
(*pROI_coords)[3] = 4.0;
(*pROI_coords)[4] = 5.0;
(*pROI_coords)[5] = 6.0;
(*pROI_coords)[6] = 7.0;
(*pROI_coords)[7] = 8.0;
(*pROI_coords)[8] = 9.0;
(*pROI_coords)[9] = 10.0;
return S_OK;
}
Best of luck,
Bio.
|
|
|
|
|
Yes, my code is very similar to your example.
1. I have verified that the value for pNum_ROI_nodes is positive and the correct value for the situation.
2. I have seen that all of the values do get loaded into the memory assigned for the array on the server side in the server's memory space.
3. Upon return to the client side, I can see that the value returned for the pNum_ROI_nodes is still the correct value and is in the client memory space, but upon trying to read the values with:
for (int i = 0; i < pNum_ROI_nodes * 2; i++)
{
pfCoordValue[i] = (float)pROI_coords[i]; //retrieve the values to local array
}
CoTaskMemFree(pROI_coords); //delete the array created within the COM server object
At this point, the only value that is in the array pROI_coords, is the very first value loaded. In your example, it would be the value of 1.0. All other values are none existent and it is clear from the memory contents that the array is not initialized past one value. It appears that the marshaller is only moving one item of the array to the client side.
Vita has suggested that the marshaller does not understand the size_is command, maybe he is on to something...
Regards,
David
|
|
|
|
|