|
There is more than one article on codeproject on how to do this.
Search for singleton, single instance, etc.
Iain.
|
|
|
|
|
trioum wrote: can any one told me how it is possible
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I like to create a out of process(seperate application) webbrowser from one applicationa and want to control this webbrowser from the main program.
Any idea or link would be very helpful?
Thank you.
|
|
|
|
|
The are a lot of ways of course.
You may use a form of Interprocess Communication http://msdn2.microsoft.com/en-us/library/aa365574.aspx[^]
or you can build a COM out-of-process server (COM is a rather big topic however).
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.
|
|
|
|
|
hi all,
I am using ORCA to validate the product key in C# 2005 windows application.
i am using the following C++ code in a dll to be added to the MSI for validation.
UINT __stdcall ValidateSerial(MSIHANDLE hInstall)
{
TCHAR szPidKey[PIDKEY_LENGTH];
DWORD dwLen = sizeof(szPidKey) / sizeof(szPidKey[0]);
///retrieve the text entered by the user
UINT res = MsiGetPropertyA(hInstall, _T("PIDKEY"), szPidKey, &dwLen);
if(res != ERROR_SUCCESS)
{
//fail the installation
return 1;
}
bool snIsValid = true;
//validate the text from szPidKey according to your algorithm
//put the result in snIsValid
//the template we use is <###-####> = <xyz-abcd>; # digit between 0 and 9
//the algorithm is very simple (XY * Z + 7) * 13 = ABCD / 2
int xy = DIGIT(szPidKey[0]) * 10 + DIGIT(szPidKey[1]);
int z = DIGIT(szPidKey[2]);
int left = ((xy * z + 7) * 13 ) * 2;
int right = DIGIT(szPidKey[4]);
right = right * 10 + DIGIT(szPidKey[5]);
right = right * 10 + DIGIT(szPidKey[6]);
right = right * 10 + DIGIT(szPidKey[7]);
snIsValid = (left != 0) && (right != 0) && (left == right);
TCHAR * serialValid = NULL;
if(snIsValid)
serialValid = _T("TRUE");
else
{
//eventually say something to the user
::MessageBox(0, _T("Invalid Serial Number"), _T("Message"), MB_ICONSTOP);
serialValid = _T("FALSE");
}
res = MsiSetPropertyA(hInstall, _T("SERIAL_VALIDATION"), serialValid);
if(res != ERROR_SUCCESS)
{
//fail the installation
return 1;
}
//the validation succeeded - even the serial is wrong
//if the SERIAL_VALIDATION was set to FALSE the installation will not continue
return 0;
}
but when i execute the above code, i am getting the following error.
error LNK2019: unresolved external symbol _MsiSetPropertyA@12 referenced in function "unsigned int __stdcall ValidateSerial(unsigned long)" (?ValidateSerial@@YGIK@Z) CustomAction.obj
i have included <msi.h> and <msiquery.h>
I am a beginner in VC++ and could anybody help me with some suggestions
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
how to copy a dialog from one project to other project? I want to reuse the existing dialog present in one project to a new project whioch i am working on. Can any one help me out in solving this.
Naveen
|
|
|
|
|
Open .rc file in IDE and just copy and paste will do.
Regards,
Paresh.
|
|
|
|
|
Paresh.... What my problem is that I have 4 dialogs in my existing project and i want only one in that four for reuse in my new project. How could i do this ? Help me out.
|
|
|
|
|
u require the design and code or only design?
|
|
|
|
|
I want only design and not code.
|
|
|
|
|
then its simple...
u should be having the rc file of the old application. drag that to the new applcation. since ur application will be minimised just need to drag and position it on top of the new application. dont drop it. once it loads the page automatically maximises. then drop it. copy the design close the rc file and paste the design...
hope u understood.
|
|
|
|
|
See Mr Chandrasekharan...... I think u have not understood my problem.
Lets Suppose I have an old application which contains 4 dialogs. A,B,C,D
In the new application which i am developing i have three new dialogs F,G,A,H.
note: "A" got repeated. So i have to copy the same dialog from my old application to new one with all the controls so that it reduces time for me in developing the entire dialog once again.
|
|
|
|
|
naveen27gupta wrote: Help me out.
Open .rc file in IDE, and copy/paste just the dialog template you are interested in.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I really what read some information from my USB device.My two task are these:
1.When I scan a USB device plugged,I want to get its driver letter like G,H,and so on.For example,i get a device instance like "USB\VID_0AC8&PID_301B\5&37FD04DB&0&2" using SetupDiGetInterfaceDeviceDetail,so I using that path to create a HANDLE(using ZwOpenFile),then I want to call ZwQueryInformationFile() to get some information,or call ObReferenceObjectByHandle().But these functions are decleared in wdm.h or ntddk.h.
2.The document of my USB device(or storage)says that,the special information should be retrieve by SCSI INQUIRY,I find it is IOCTL_SCSI_GET_INQUIRY_DATA command.But I do not know how to do.
I will be very appreciated if someone give me some advice.
Thanks.
|
|
|
|
|
kcynic wrote: .When I scan a USB device plugged,I want to get its driver letter like G,H,and so on.For example,i get a device instance like "USB\VID_0AC8&PID_301B\5&37FD04DB&0&2"
Now through which mehtod ur detecting the USB is plugged? WM_DEVICECHANGE?
|
|
|
|
|
No,I only retrieve the USB device by accessing all the usb hub port to see whether there are some USB devices plugged in.
|
|
|
|
|
When a USB device is plugged, all the top level windows will receive a WM_DEVICECHANGE message. An in such case you can retrive the drive letter from the structure pointed by the LPARAM of that message. Check the MSDN for the help of WM_DEVICECHANGE.
|
|
|
|
|
And my program is not a GUI project,only a console project,because there is no need to retrieve windows messages.In fact,my program would be run when the USB devices had been plugged in.By now,if there only has one specified USB device,my program works well,and if there are more than one such USB device,it does not know which USB device it really want to operate.(In addition,one such USB device can be treate as a mass storage.
|
|
|
|
|
ok. I can help u with the first task( calling the ZwOpenFile() and ZwQueryInformationFile()).
1 . copy all the necessary structure for those function from the ntddk.h file to ur local file
2. now create a pointer for that function. like
typedef NTSTATUS (*pZwOpenFile)(<br />
OUT PHANDLE FileHandle,<br />
IN ACCESS_MASK DesiredAccess,<br />
IN POBJECT_ATTRIBUTES ObjectAttributes,<br />
OUT PIO_STATUS_BLOCK IoStatusBlock,<br />
IN ULONG ShareAccess,<br />
IN ULONG OpenOptions<br />
);
3. Now use LoadLibrary to load the ntdll.dll. HMODULE hModule = LoadLibrary( _T("ntdll.dll"));
4. Now call GetProcAddress() function to get of the ZwOpenFile function.
pZwOpenFile ZwOpenFile = (pZwOpenFile )GetProcAddress( hModule, "ZwOpenFile" );
now u can call ZwOpenFile like any other functions.
|
|
|
|
|
Yes,that is a good idea.
And if you known some about the 2nd question?
Thank you very much.
|
|
|
|
|
|
Yes,perhaps that can.
But I tried several times of the IOCTL_SCSI_GET_INQUIRY_DATA.But it faild for every of my USB stroage except my IDE storage.
I search the reason on the internet,someone said that,that ioctl would faild for usb device,but use SCSI_INQUIRY(operation code:0x12h) command to the device.
But I am not a driver programmer,I only a application programmer,so I only know a little about WDM.
I do not know how to do such task.
|
|
|
|
|
did u search in google. I found some sample that use SCSI_INQUIRY. One of them here[^]
|
|
|
|
|
In fact,not because I am lazy.I am a Chinese,so I read English a little slowly.On the other side,in my local area,the search engine will list the linkers in my own language priority.
By now,I do not know the liker you given to me works well or not,but I will have a try.
And I will learn English more hard.I can see,I will read English words as fast as reading my own language.
Thank you very much.
BEST WISHES.
|
|
|
|
|
Repost of my answer in our earlier discussion, just so it is complete in the archives:
You can do this without using the functions from wdm and ntddk. After you get your device's name using the SetupDi functions, open a handle using CreateFile . Then use DeviceIoControl to send the IOCTL_SCSI_GET_INQUIRY_DATA to the device. Google on that IOCTL and you'll find some examples of calling it from user mode.
Judy
(fixed my cut-and-paste HTML)
modified on Tuesday, December 18, 2007 1:29:05 PM
|
|
|
|