|
I created a vb6 activex control which I'm using in Word.
I call it from word and it does its thing.
But the control remains on the document.
How can I code (with vb) a command button on the control
so that the control is 'terminated?"
|
|
|
|
|
Why do you want to destroy it before the document closes?
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
How to determine a UserID (in Windows) is a member of a certain UserGroup (like SalesManagers) in VB.Net?
I tried DirectoryEntry and DirectorySearcher in the System.DirectoryServices name spaces, but I cannot get it to work. I also tried WindowsIdentity and WindowsPrincipal.IsInRole but with no correct result. I cannot find any sample codes.
Any suggestion?
Thanks
|
|
|
|
|
Here is the function that I have for a project that I was working on.
Good luck...
Imports System.DirectoryServices
Friend Function VerifyUser(ByVal Username As String, ByVal Password As String, ByVal groupType As EGroupType) As Boolean
Dim RootDomain As New DirectoryEntry("LDAP://rootDSE")
Dim strDNC As String = RootDomain.Properties("DefaultNamingContext")(0)
Dim UserEntry As New DirectoryEntry("LDAP://" & strDNC, Username, Password)
Dim Searcher As DirectorySearcher = New DirectorySearcher(UserEntry)
Dim SearchResults As SearchResultCollection
Dim SearchResult As SearchResult
Dim GroupPresentFlag As Boolean
Dim Data As String
Dim Cnt As Integer
Dim ResultCollection As ResultPropertyCollection
Dim ValueCollection As ResultPropertyValueCollection
Dim m_configSettings As New GlobalData()
Username = Username.Trim(" ")
Password = Password.Trim(" ")
Searcher.Filter = ("(samaccountname= " & Username & ")")
Searcher.PropertiesToLoad.Add("memberOf")
GroupPresentFlag = False
Try
SearchResults = Searcher.FindAll
Catch Ex As Exception
End Try
For Each SearchResult In SearchResults
ResultCollection = SearchResult.Properties
Next
ValueCollection = ResultCollection.Item("memberOf")
For Cnt = 0 To ValueCollection.Count - 1
Data = CType(ValueCollection(Cnt), String)
Select Case groupType
Case EGroupType.Users
If InStr(Data, m_configSettings.ADUserGroupName, CompareMethod.Text) Then
GroupPresentFlag = True
End If
Case EGroupType.Poweruser
If InStr(Data, m_configSettings.ADPoweruserGroupName, CompareMethod.Text) Then
GroupPresentFlag = True
End If
Case EGroupType.EarlyAdopter
If InStr(Data, m_configSettings.ADEarlyadopterGroupName, CompareMethod.Text) Then
GroupPresentFlag = True
End If
Case EGroupType.Admin
If InStr(Data, m_configSettings.ADAdminGroupName, CompareMethod.Text) Then
GroupPresentFlag = True
End If
End Select
Next
If (Not m_configSettings Is Nothing) Then
m_configSettings = Nothing
End If
Return GroupPresentFlag
End Function
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Thanks Ray for your sample. I just found out that my company does not have LDAP yet. Only Windows 2000. So, I guess I cannot use the DirectorySearcher in this case. What is your comment on this? Am I out of luck?
Thanks.
|
|
|
|
|
Are they using Active Directory? That is all that I am using.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Yes. But the path would be like this "WinNT://DomainName/GroupName". I tried the following codes and I can see the GroupName there but I cannot see the members contain inside the group.
Dim DEntry As New DirectoryServices.DirectoryEntry("WinNT://DomainName")
Dim UserGrp As DirectoryServices.DirectoryEntry
For Each UserGrp In DEntry.Children
If UserGrp.Path = "WinNT://DomainName/GroupName" Then
MessageBox.Show(UserGrp.Path)
End If
Next
There, you can try it out. Again, many thanks, Ray.
|
|
|
|
|
I have created a windows service but how do you run the code in the IDE so you can step through and debug it?
|
|
|
|
|
You have to install it, start it then attach to it in the debugger. This will cause you to miss being able to really debug any code in the starting events.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
What a pain! Do you know if you can have a System Tray Icon with a menu Associated with your service. I tried setting up a NotifyIcon, it runs through the code to set it up fine but it never appears in the system tray.
|
|
|
|
|
One trick I've been using is to put most of the initialization code in a one-shot timer (.AutoReset=False) and set the interval on that timer for something like 30-45 seconds. That gives you the time to connect the debugger to your service before that code starts.
Since my service is based around another timer, I just leave my main timer disabled until the initialization timer fires. Put your first breakpoint in the initialization timer and you can then debug that code.
Once you are happy with your initialization code, you can speed things up by changing the initialization timer's interval to something much shorter. Don't change the structure for production, just shorten the interval. If you need to re-debug something in the init code, you only have to change your interval again.
|
|
|
|
|
Two more questions.
1. How can I make my service handle the Pause and Continue events? I have the code for these events in my service (OnPause and OnContinue) but these selections are not available to me in the Service Manager. Also I wrote a custom app to control services, when I call the pause method against my service I get an exception because the service does not handle these events. (System.InvalidOperationException: Cannot pause Esanti_Core service on computer '.'. ---> System.ComponentModel.Win32Exception: The requested control is not valid for this service)
2. How can I write a service install function from a custom app?
|
|
|
|
|
Well I found the answer to my first question. You have to set the CanPauseAndContinue property in the InitializeComponet sub. i.e. Me.CanPauseAndContinue = true
|
|
|
|
|
The easier way of all (in my opinion) is to set up ASSERT and TRACE in your code.
Use the Debugview from www.sysinternal.com to trace your code but make sure your service is in debug mode.
Or use some debugging tool like softice and etc.
|
|
|
|
|
Hi.
I need some help. I'm trying to add user controls dynamically to a tabpage's controls collection. The problem is, once they've been added, i don't know how to listen for events raised within the user controls. Is there some control-object event handler?
HELLLP.
Thanks in advance.
DI
|
|
|
|
|
Take a look in the help for addhandler. This should do the trick for you.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Events are handled in a good new way in .NET. When you want to listen to an event, you do this:
button.Click += new System.EventHandler(buttonClick)
where button.Click is the event, and buttonClick is a method with the correct arguments. When handling multiple controls' events, use the "Sender As Object" argument of the method you assigned to the event to find out which object fired the event.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
How to check if file existe in VB?
Thanks for any reply.
|
|
|
|
|
Hi,
Just use "Dir" command in VB to check it's existance.
Say,
if Dir("filename") then
'' Task to do if file exists
end if
It will retrun True if exists or False if file is not there on the mentioned path. You can use other parameters like vbDirectory, vbSystemFile etc. to check file or folder property.
Best Regards,
Vilas Shewale
|
|
|
|
|
Thanks so much for your reply.
|
|
|
|
|
Here is another way.
If IO.File.Exits("FileName") Then
'Do something
End If
|
|
|
|
|
Anybody had this problem before. I am trying to download a webpage using the URLDownloadToFileA API decalred in urlmon from VB .net and it is not downloading and the returns long value. I tried to trnslate the error code "underlaying portocol is unknown"
Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
src as string, dest as string
lResult as long
src = "http:\\www.msn.com"
dest = "c:\images\x.html"
lResult = URLDownloadToFile(0, src, dest, 0, 0)
but the same code works very well in VB 6.0. I can download pages with out a problem.
any help appricated.
-Murali
|
|
|
|
|
How about using the .NET framework WebRequest and Stream to read the data from the URL, then use a FileStream to write it out to a file?
There's and example of the read step on GotDotNet, http://samples.gotdotnet.com/quickstart/howto/doc/WebRequests/clientGET.aspx
And as for writing it to a file, the .NET library sample:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemIOFileStreamClassTopic.asp
|
|
|
|
|
Hello all,
What are the date functions in VBA? I have a string in my Access 2000 code, and I'd like it to hold today's date. What do I call to get the date?
Dim theDate as string
theDate = date()
I know that is wrong, but what do I do?
Thanks
Nick
|
|
|
|
|
In VBA/MS Access Macro code, something like this should place today's date into a string:
Dim myDate As Date
Dim myDateString As String
myDate = Date
myDateString = CStr(myDate)
MsgBox myDateString
Hope that helps.
|
|
|
|