|
I had to do the same thing recently and I settled on the volume serial no ( which will change on a reformat, but at least doesn't need admin rights to access )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian
To be honest I wanted to settle for this myself but then again that increases the 'hassle factor'. From my experience customers reformat drives more often that they change them let alone change part of the system.
Besides using just a volume serial gives you one point of reference whereas proc mobo ram and HD manufacturer assigned serials give you a way of reducing headaches. Say only 2 out of 4 match the app can still function.
I could put admin rights as a requirement for the app but that option is reserved for when I hit the rock bottom and dig into 50 feet of crap .
I appreciate your response but still would like to get more info on this issue.
The perfect code is always in your head...it just a matter of how hard you bang your head against the wall to get it out!
|
|
|
|
|
Yes, I have to admit that I wanted to go the HDD serial route, but I couldn't find a way to make it happen, and our needs were somewhat specific, such that the compromises you mention were regarded as being not a problem.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
I played with the .net settings and tools and then read stuff from here (www.informit.com[^]) and there (msdn.microsoft.com[^]) and it all became clear as mud .
The reason my test app didn't function was because it was run from the server (ie permission set Intranet) hence the ugly security exceptions. However, the actual application is intended to be run locally thus requiring the user to be an admin on the local pc is not that much to ask considering that the application my app extends has that requirement anyway.
Once again thanks for your time Christian
Regards
Alex
The perfect code is always in your head...it just a matter of how hard you bang your head against the wall to get it out!
|
|
|
|
|
Hi
How can i edit the legend of the graph in the crystal report.
I cant find any option for the same
Please Help me.
Thanx
Riyaz Zujer Patanwala
I.T.Programmer
Al Jaber Energy Services
P.O.Box 47467
Abu Dhabi
U.A.E.
|
|
|
|
|
I have an MDI form where I set the following Handler in Form_Load
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
If I throw an exception in the MDI form the exception gets handled by CurrentDomain_UnhandledException
But, If I load a child form and throw an exception from the child form the excpetion does not get handled by CurrentDomain_UnhandledException
So, Is the child form running in a different AppDomain then the MDI form. How can I get this to work or does this not work the way I thought it would.
Here is my form load which is also in the MDI form
f = New formDesignErrorsList<br />
f.Tag = formname<br />
f.Text = f.Text<br />
f.MdiParent = Me<br />
f.Show()
Thanks
-- modified at 22:46 Wednesday 23rd August, 2006
|
|
|
|
|
mtone wrote: Is the child form running in a different AppDomain then the MDI form.
No, it's not. It's all in the same AppDomain.
What's the exception that's not getting handled?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
In the Main (MDI) form My test is just trowing an new exception. Here is gets handled by CurrentDomain_UnhandledException and ultimatly ends up in The EventLog
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
AddHandler Application.ThreadException, AddressOf ApplicationThreadException<br />
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException<br />
Throw New Exception("This is a test")<br />
End Sub
If I put the same Throw New Exception("This is a test") in the onload event of the mdi child it does not get handled nor does it make it to the event log. If I set a break point I can see that CurrentDomain_UnhandledException is never called.
Thanks
Joe
|
|
|
|
|
Well, I did this and it did what was expected of it:
' Form1
Private Sub Form1_Load(blah, blah) Handles Me.Load
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionHandler
Dim c As New Form2
c.MdiParent = Me
c.Show()
End Sub
Private Sub UnhandledExceptionHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
Debug.WriteLine("Unhandled Exception!!")
End Sub
' Form2
Private Sub Form2_Load(blah, blah) Handles Me.Load
Throw New Exception("Yikes!")
End Sub
The exceptions don't make it to the event log because there's nothing telling the app to log them. But, the exception was caught by the UnhandledExceptionHandler.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave
I have the code that writes to the event log in another function I am using the Enterprise Library to handle the event logging. Well, the event log was not the problem just a way for me to see the exception followed the proper route. I will keep looking at it, so long as I know it should work.
|
|
|
|
|
In my testing, there is a problem with using the UnhandledException event. It doesn't get fired unless the code is running under the debugger! Go figure...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i had found my error which is the DATE cause the problem...
anyway to update my DATE field?? will it becasue of the format? because i found out that my vb when i put"NOW" it will include the time with it. But with my access i had set it as DATE only.
Date= " & "'" & ddate.Text & "'" & _
Here my full coding:
DB.Execute "update DONO set NO=" & "'" & dono.Text & "'" & _
",Date= " & "'" & ddate.Text & "'" & _
",Customer=" & "'" & Combo1.Text & "'" & _
",Description =" & "'" & ddes.Text & "'" & _
",Total =" & "'" & temptotal.Caption & "'" & _
",BillTerm=" & "'" & dterm.Text & "'" & _
" where [dono] = " & "'" & userin & "'"
|
|
|
|
|
It depends on what database you are using.
Mike Lasseter
|
|
|
|
|
i'm using microsoft access
|
|
|
|
|
For using dates in access you will need to use # around the date instead of '.
Example: #8/23/06#
Mike Lasseter
|
|
|
|
|
not working
here coding:
",Date= " & "'" & "#" & ddate.Text & "#" & "'" & _
even i put it as ",Date= " & "'#" & ddate.Text & "#'" & _
not working too
|
|
|
|
|
",Date= " & "'" & "#" & ddate.Text & "#" & "'" & _
even i put it as ",Date= " & "'#" & ddate.Text & "#'" & _
The above lines equate to the same sting to send to the database. Both of which have ' around the date still. You don't need the single quotes for dates in access.
Use the following:
",Date= " & "#" & ddate.Text & "#" & _
Mike Lasseter
|
|
|
|
|
|
Standard question #1:
What do you mean by "not working"?
Standard question #2:
What error message do you get?
You are probably using a date format that the database doesn't recognise.
---
b { font-weight: normal; }
|
|
|
|
|
pls refer to mr_lasseter response , i have try many way of those format. but when i save a new record it able to save it but when update , which mean edit the old record then have problem.
|
|
|
|
|
Guffa's questions are valid. From the last attempt that you made:
Standard question #1:
What do you mean by "not working"?
Standard question #2:
What error message do you get?
|
|
|
|
|
I would use the debugger to step the code and see what the update string that is sent to the database looks like. I would take this string and try to run it as a query in access. Figure out what you need to do to the string in order to get it to run in Access, then make the appropriate changes in your code.
Mike Lasseter
|
|
|
|
|
Can you do something like this?
Date= " & "'" & Now.ToShortDateString & "'" & _
Roy.
|
|
|
|
|
having error : Object require.
|
|
|
|
|
Hi:
I have the following code in VB 2005 and I´m using a C++ DLL (SNAPI.DLL) from Symbol (DS6607 Barcode and Image Scanner). On Symbol´s website (www.symbol.com) I found the SNAPI.DLL, SNAPI.LIB and the SNAPI.H files. I am getting a Writing Protected Memory error when I try to read the data returned by the DLL (unmanaged code). Does anyone have any suggestions on where to find a solution?
Thanks for any suggestions.
Jaime A.
Imports System<br />
Imports System.Runtime.InteropServices<br />
Imports System.Resources<br />
Imports System.IO<br />
<br />
.<br />
.<br />
.<br />
<br />
' The SNAPI.dll is an unmanaged DLL written in C++ and we only have available the SNAPI.dll, the SNAPI.lib and the SNAPI.h<br />
Declare Auto Function SNAPI_Init Lib "SNAPI.dll" (ByVal HWND As IntPtr, ByRef DeviceHandle As IntPtr, ByRef NumDevices As IntPtr) As Integer<br />
Declare Auto Function SNAPI_Connect Lib "SNAPI.dll" (ByVal DeviceHandle As IntPtr) As Integer<br />
Declare Auto Function SNAPI_Disconnect Lib "SNAPI.dll" (ByVal DeviceHandle As IntPtr) As Integer<br />
Declare Auto Function SNAPI_GetSerialNumber Lib "SNAPI.dll" (ByVal DeviceHandle As IntPtr, <MarshalAs(UnmanagedType.SysInt)> ByRef SerialNo As IntPtr) As Integer<br />
Declare Auto Function SNAPI_SoundBeeper Lib "SNAPI.dll" (ByVal DeviceHandle As IntPtr, ByRef nBeepCode As Byte) As Integer<br />
Declare Auto Function SNAPI_SetVersionBuffer Lib "SNAPI.dll" (ByVal DeviceHandle As IntPtr, ByRef DataPtr As IntPtr, ByVal max_length As Int32) As Integer<br />
<br />
'Handles and Messages<br />
Dim Status As Int32 = 0<br />
Dim devhandle As IntPtr<br />
Dim numdev As IntPtr<br />
Dim serialno(255) As Byte<br />
Dim resultStr As String<br />
Dim ptr As IntPtr = Marshal.AllocHGlobal(256)<br />
<br />
' These are some beep codes for the beep functions<br />
Const ONESHORTHI As Byte = &H0<br />
Const TWOSHORTHI As Byte = &H1<br />
Const THREESHORTHI As Byte = &H2<br />
Const FOURSHORTHI As Byte = &H3<br />
Const FIVESHORTHI As Byte = &H4<br />
<br />
'C++ Definitions in SNAPI.H<br />
'SNAPIDLL_API int __stdcall SNAPI_Connect(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_Init(HWND hwnd, HANDLE * DeviceHandles, int * NumDevices)<br />
'SNAPIDLL_API int __stdcall SNAPI_Disconnect(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_SnapShot(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_TransmitVersion(HANDLE DeviceHandle)<br />
'<br />
'SNAPIDLL_API int __stdcall SNAPI_PullTrigger(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_ReleaseTrigger(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_SetParameters(WORD *Params, int ParamWords, HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_TransmitVideo(HANDLE DeviceHandle) <br />
'SNAPIDLL_API int __stdcall SNAPI_RequestParameters(WORD *Params, int ParamWords, HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_RequestAllParameters(HANDLE DeviceHandle)<br />
<br />
'SNAPIDLL_API int __stdcall SNAPI_AimOn(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_AimOff(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_LedOn(HANDLE DeviceHandle, unsigned char nLEDselection)<br />
'SNAPIDLL_API int __stdcall SNAPI_LedOff(HANDLE DeviceHandle, unsigned char nLEDselection)<br />
'SNAPIDLL_API int __stdcall SNAPI_ScanEnable(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_ScanDisable(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_SoundBeeper(HANDLE DeviceHandle, unsigned char nBeepCode)<br />
'SNAPIDLL_API int __stdcall SNAPI_EnterLowPwrMode(HANDLE DeviceHandle)<br />
<br />
'SNAPIDLL_API int __stdcall SNAPI_RequestScannerCapabilities(HANDLE DeviceHandle)<br />
'SNAPIDLL_API int __stdcall SNAPI_SetParamPersistance(HANDLE DeviceHandle, int bPersist)<br />
'SNAPIDLL_API int __stdcall SNAPI_AbortMacroPdf(HANDLE DeviceHandle) // aborts macro session and throws out any data<br />
'SNAPIDLL_API int __stdcall SNAPI_FlushMacroPdf(HANDLE DeviceHandle)
'SNAPIDLL_API int __stdcall SNAPI_SetParameterDefaults(HANDLE DeviceHandle)<br />
<br />
'SNAPIDLL_API unsigned int __stdcall SNAPI_ReturnDLLVersion(void)<br />
'SNAPIDLL_API int __stdcall SNAPI_GetSerialNumber(HANDLE DeviceHandle,unsigned char * SerialNo)<br />
'
<br />
'SNAPIDLL_API int __stdcall SNAPI_SetVideoBuffer(HANDLE DeviceHandle, unsigned char *pData, long max_length)<br />
'SNAPIDLL_API int __stdcall SNAPI_SetImageBuffer(HANDLE DeviceHandle, unsigned char *pData, long max_length)<br />
'SNAPIDLL_API int __stdcall SNAPI_SetDecodeBuffer(HANDLE DeviceHandle, unsigned char *pData, long max_length)<br />
'SNAPIDLL_API int __stdcall SNAPI_SetVersionBuffer(HANDLE DeviceHandle, unsigned char *pData, long max_length)<br />
'SNAPIDLL_API int __stdcall SNAPI_SetCapabilitiesBuffer(HANDLE DeviceHandle, unsigned char *pData, long max_length)<br />
<br />
'This is the First Subroutine to be called<br />
Private Sub cmdSNAPI_Init_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SNAPI_Init.Click<br />
Status = SNAPI_Init(WinHandle, devhandle, numdev).ToString<br />
End Sub<br />
<br />
'This is the Second Subroutine to be called<br />
'It then calls SNAPI_GetSerialNumber to obtain the serial number from the SYMBOL DS6607 Barcode scanner<br />
<br />
Private Sub cmdSNAPI_Connect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click<br />
lblConnect.Text = SNAPI_Connect(devhandle).ToString<br />
lblDLLVer.Text = "DLL Version: " & SNAPI_ReturnDLLVersion()<br />
Status = SNAPI_GetSerialNumber(devhandle, ptr)<br />
resultStr = Marshal.PtrToStringAuto(ptr, 256)<br />
'@@@@@@@@@@@@@@ I get a ATTEMPTED TO READ OR WRITE PROTECTED MEMORY at this point, any suggestions ? @@@@@@@@@@@@@@<br />
End Sub<br />
<br />
'This is the Last Subroutine to be called to Disconnect from the SYMBOL DS6607 Barcode scanner<br />
Private Sub cmdSNAPI_Disconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSNAPI_Disconnect.Click<br />
Status = SNAPI_Disconnect(devhandle)<br />
End Sub<br />
<br />
Private Sub cmdSNAPI_SoundBeeper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSNAPI_SoundBeeper.Click<br />
Status = SNAPI_SoundBeeper(devhandle, FIVESHORTHI)<br />
End Sub
|
|
|
|