|
Hi ,
Thanks for the immediate response . I need to enter 15 digits and it shud check whether the 15 digits are entereed i.e if i try to enter 13 digits it shudn't allow me proceed further . hope you get what i mean . This is actually an install shield which i 'm creating in which i have a user registration dialog in which i will have cust enter serial number so i need a code to check that whether he or she has entered correctly 15 digits
for ex :
// Serial Validation DLL.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#define PIDKEY_LENGTH 100
#define DIGIT(a) ((a) - '0')
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
return TRUE;
}
UINT __stdcall ValidateSerial_Sample(MSIHANDLE hInstall)
{
TCHAR szPidKey[PIDKEY_LENGTH];
DWORD dwLen = sizeof(szPidKey) / sizeof(szPidKey[0]);
///retrieve the text entered by the user
UINT res = ::MsiGetProperty(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;
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 = ::MsiSetProperty(hInstall, _T("SERIAL_VALIDATION"), serialValid);
if(res != ERROR_SUCCESS)
{
return 1;
}
//the validation succeeded - even the serial is wrong
//if the SERIAL_VALIDATION was set to FALSE the installation
//willl not continue
return 0;
}
But i need to check for 15 digits . Can you please send the code for this .
Thanking you ,
Ovia
|
|
|
|
|
ovia wrote:
I need to enter 15 digits and it shud check whether the 15 digits are entereed i.e if i try to enter 13 digits it shudn't allow me proceed further .
What about:
BOOL IsSerialNumberValid(...)
{
if (_tcslen(szPidKey) != 15)
return FALSE;
for (int x = 0; x < 15; x++)
{
if (! isdigit(szPidKey[x]))
return FALSE;
}
return TRUE;
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hallo Sir ,
can you please send me the whole program that would be of great halp to me. Please because i really don't know how to insert the sample you have send me . please help me out
Ovia
|
|
|
|
|
The code is useable as it is, just copy and paste it in. Call it like you would any other function. However, after reading the rest of your original post, it's not going to help you that much because of the other validation you require.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hi,
i want to delete the resouce in such a way:
UpdateResource(
m_hModule,
"MY_RES_TYPE",
MAKEINTRESOURCE( IDR_MY_RES1 ),
MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ) ,
NULL,
0 );
MSDN:
If lpData is NULL, the specified resource is deleted from the executable file.
GetLastError ===87 — The parameter is incorrect. How can i handle this???
If i do this:
UpdateResource(
m_hModule,
"MY_RES_TYPE",
MAKEINTRESOURCE( IDR_MY_RES1 ),
MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ) ,
lpData,
1 );
UpdateResource(
m_hModule,
"MY_RES_TYPE",
MAKEINTRESOURCE( IDR_MY_RES1 ),
MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ) ,
NULL,
0 );
everything's going OK but resouce isn't deleted.
|
|
|
|
|
Are you sure that the resource exists? Did you call EndUpdateResource() ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
the problem is with the resource type which shouldn't be put in quotes. The resource type should either be one of the default resource types(e.g. RT_STRING ) or it should be the result of calling MAKEINTRESOURCE macro
|
|
|
|
|
(ATL/COM/MFC/C++)
HI, I'm beginner about Window programming
I'd like to develop a small dll that has a function.
There is one text(txt file) loaded on IE.
The txt contains just a words like "Hello!!".
I've made that the "Hello!!" has focus of cursor.
I mean If I move cursor on "Hello!!"
then arrow-shaped cursor would be changed to hand-shape on a web page.
Now, If I click the "Hello!!",
the programe opens new dialog that has a static text.
The static text shows me "Hello!!".
That's all. How can I make this?
any reply, any URL contains some reference about this, offer me please.
|
|
|
|
|
Ummmmmm it's called HTML I think no?
|
|
|
|
|
I know it's easy to develop with HTML.
But I want to make it with ATL/COM/MFC/C++.
help me~
|
|
|
|
|
Can anyone tell me what the pointery bit here means?
DSA_REQ = (M802_16eDSA_REQ*)packetMsg->packet;
|
|
|
|
|
sroberts82 wrote:
(M802_16eDSA_REQ*)packetMsg->packet;
The pointery bit here means that he is typecasting the packetMsg->packet to a pointer to a M802_16eDSA_REQ type.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello friends,
In vc++ it is possible to generate asm code for a particular cpp file. My question is
Since assembly language instruction is processor dependent, Can you please tell me on which mircroprocessor assembly level language does the vc++ tool can generate asm file.
Hoping for a positive reply.
|
|
|
|
|
Hi ,
It generates the listing for 386 and above. It uses the instruction set for 386 for the listing files.
thanks,
Suresh Ponnusami
|
|
|
|
|
It should do that for every processor the compiler is able to write code for.
Don't try it, just do it!
|
|
|
|
|
phijophlip wrote:
In vc++ it is possible to generate asm code for a particular cpp file.
Yes, it's possible.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi,
I want to extract NETBIOS name using DNS
For this I am using IADsNameTranslate object of ADSI API
This is the error message I am getting
error: 'IADsNameTranslate' undeclared identifier
It seems like that IADsNameTranslate is supported on Dot net compiler and not on Visual studio 6.0 compiler
Can someone confirm this and suggest some workaround.
Thanks and Regards
Ankur
|
|
|
|
|
|
Hi,
Thanks for your reply.
Its not possible to upgrade SDK for me.
I have to implement this functionallity without upgrading SDK / Compiler.
Please tell me if there's any other approach to this.
IADsNameTranslate is working on dotnet compiler.
Please tell me how NetBIOS name can be extracted from AD using domain name.
Thanks and Regards
Ankur
|
|
|
|
|
i have developed and application where i handle the WM_ENDSESSION
ON_MESSAGE(WM_ENDSESSION,OnMyEndSession)
LRESULT CMyDlg::OnMyEndSession(WPARAM wParam, LPARAM lParam)
{
ShellExecute ( NULL, "open", "C:\\abc.exe, NULL, NULL, SW_HIDE ) ;
}
But the executable(abc.exe) is not executed.
|
|
|
|
|
What does OnMyEndSession() return? What is the value of wParam ?
You should probably handle the WM_QUERYENDSESSION message instead. This message is sent first, and if all applications respond with TRUE , Windows is going to shut down/restart. It wouldn't make sense to start up another application at this point since it would have not had a chance to respond to the WM_QUERYENDSESSION message.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
dear All,
Just wondered if one knows how to use an array in enum.
this would be more convenient then 100 diffreent variables.
many thanks, Dominik
|
|
|
|
|
I'm not quite sure I understand your question. The enum statement takes the form:
enum Colors
{
Red,
Blue,
Green,
Yellow,
Brown
}; At this point, there are no variables, only one enumerable type.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
As unsure as DavidCrow in what you mean. Assuming you mean an array of enumerated values, then the answer is simple:
typedef enum {
Blue, Red, Yellow
} Color;
Color colors[100];
Otherwise... please clarify.
|
|
|
|
|
I think he needs a struct or class. He's thinking along these lines (I think)
typedef enum
{
Blue,
Red,
Yellow,
int nTypes[9]
};
I don't think this is possible in an enum
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|