|
Hi All,
I finally got solution of this issue myself. My application was having a code where I was impersonating a admin user and then doing some stuff. On debugging more i found that my application was not running beyond the point where i was passing token of impersonation to next command. Then i changed the security policy of my Win 7 system and added my user in following security policy "create token" something.. and this resolved my issue.
Hope it will be useful for somebody.
Regards,
|
|
|
|
|
I have following problem in my VB6 project:
I have an array of 44 bytes, aTZI(), which is a result of WMI objRegistry.GetBinaryValue call.
I also have defined a user types and a variable:
Public Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Public Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(0 To 63) As Byte
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(0 To 63) As Byte
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Public zoneTZI As TIME_ZONE_INFORMATION
How can I get aTZI into zoneTZI, so that I can read each element of the TIME_ZONE_INFORMATION?
Whatever I try to do gets me an error "Only user-defined in public object modues can be coerced to or from a variant pr passed to late-bound functions"
Every suggestion will be appreciated.
Thanks!
|
|
|
|
|
Member 9539647 wrote: Every suggestion will be appreciated.
Use .NET to implement the functionality, and call it from your VB6 application.
It's not recommended to write new functionality in a deprecated language; as you already found out, support is growing thinner and will eventually disappear. You can use the VB6 Interop Toolkit to slowly migrate parts of your code to the new platform.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hello all , i'm learining VB.NET and have some questions. will you please helping me by answer them. 1- what the syntax can be used to query Entity framwork collections? is it Lambda function or LINQ expressions. 2- which vb concept is used to add extra methods that can applied to a class without use of inheritance? is it Anonymous classes or implicit typing or Nullable types or Extension methods.3- in ASP.NET ther is data-access layer created how to write a method that returns several objects to used in UI layer.
I apprecitate any help
Thank you so much and best regards
|
|
|
|
|
Smells like homework, since the answers are included in the question. The value of the question is in your research, not the correct answers; the idea is that you'd spend time on researching each of the unknowns in the question and get exposed to new knowledge.
khalid333 wrote: 1- what the syntax can be used to query Entity framwork collections? is it Lambda function or LINQ expressions.
After Googeling for "syntax ef framework", I'd vote for a LINQ expression.
khalid333 wrote: 2- which vb concept is used to add extra methods that can applied to a class without use of inheritance? is it Anonymous classes or implicit typing or Nullable types or Extension methods.
Extension methods.
Again, the answer is a bit useless - the idea is that you learn to differentiate between those items (and get to know them) so you can answer the question once your confronted with it during work: should you use an Nullable Type? Implicit Typing? What should you code when a coworker says that you'll need an "extension method"?
khalid333 wrote: <layer>.3- in ASP.NET ther is data-access layer created how to write a method that returns several objects to used in UI layer.
Same way as we pass EventArgs; you'd create a base-class that encapsulates the result-objects and return that. If you'd rather use a struct, that's possible too - but then I'd additionally recommend to make it a immutable struct.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you so much Eddy for your kind help .
|
|
|
|
|
Hi everyone out there
I have a problem (in the VERY beginning state) of writing a VB.NET DLL that will be used as a plugin for a C++ Program.
I try to outline what the goal is...
There is a videochat program called CamFrog. For this a Bot (for managing the chatroom) is available that uses plugins. The Bot comes with a C++ sample for a simple plugin. What i want to do is to "translate" that into a VB.NET Version (because C++ is really not my thing... i hardly figured out how the sample might work).
Now... I know that a .NET DLL is not the same as the C++ DLLs that are used by the bot but i guess it should be possible to achieve the same with COM Interop... I hope I'm right.
Now I looked on the sample plugin with dependency walker and it exports a few functions that will be called by the bot-program.
My first step now is to try to build a dll in VB.NET (2010 express) that ecports one simple function... i just want to see the function in dependency walker for now.
What i did so far:
I followed the guide from MS (Walkthrough: Creating COM Objects with Visual Basic[^]) using the part "Creating COM Objects without the COM Class Template
" (and some other hints from different pages i found). All settings are ok as far as i can see and my "code" is as follows:
Imports System.Runtime.InteropServices
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
Public Const ClassId As String = "C4889882-ECC6-4BBE-9B65-A9DCC30B90F8"
Public Const InterfaceId As String = "6420CC9C-2B69-4DFD-A149-C694895D80BD"
Public Const EventsId As String = "0A0ACD71-7651-4BE5-9128-FE8AECCAE623"
Public Sub New()
MyBase.New()
End Sub
<ComVisible(True)> _
Public Function testfunction() As Boolean
Return True
End Function
End Class
As far as I understood "testfunction" should now be visible as an exported function of the DLL in dependency walker...
But... it doesn't appear (list of exported functions is empty).
The whole thing with COM-Interop and that stuff is completely new for me and I barely understood all the things I read during the last 5 or 6 hours googling... so I'm sure that I miss something on it.
I hope someone can kick me in the right direction.
Thanks in advance
-obi-
|
|
|
|
|
Does the example provided by the manufacturer use COM? Well, then your idea of COM interop will be feasable.
Otherwise you should know that C++ does not mean COM! If the interface is defined with C++ header files (*.h), then you'll have to write a mixed mode (managed + unmanaged) dll in C++ which in turn can call your VB.Net dll. That is possible, but not at all easy when you do not yet understand the concepts.
|
|
|
|
|
Bernhard Hiller wrote: Otherwise you should know that C++ does not mean COM!
I knew it sounded to easy to me...
Bernhard Hiller wrote: If the interface is defined with C++ header files (*.h), then you'll have to write a mixed mode (managed + unmanaged) dll in C++ which in turn can call your VB.Net dll
There is a bunch of header files... but I have no idea how to do this "wrapper dll" in c++... also it's neccessary that my dll in turn calls functions of the c++ program (or it's dlls).
Would it be possible to do what i want using VB6 instead of vb.net? In the documentation they mentioned (in one sentence) Visual Basic and Delphi as possible languages.
I never used VB6 before (stopped using VB at VB3 and restarted with VB.NET 2010) but i think that will be much easier for me than learning C++ from scratch.
Anyway thanks for your answer Bernhard... even if I'm not really happy with my new knowledge
|
|
|
|
|
hello -
am trying to open and/or read a large csv file in VB, then write it to a txt file, starting with the 2nd line. i can open the csv, but cant seem to read (getting "past end of file" error) or write it. can manually open it in notepad and save it, then open/read THAT file, but defeats the purpose.... ideas, suggestions? thnx!
dubscat
|
|
|
|
|
Post some code and the folks here will be able to help you out.
|
|
|
|
|
sure, thanks -
been trying to approach this a couple of different ways:
FIRST -- am getting "input past end of file" error at the "split()" line, which i cant seemt to resolve:
....
BCMcsv = Dir$(BCMdrive & BCMtext)
Set objFSO = CreateObject("scripting.filesystemobject")
Set objCSV = objFSO.CreateTextFile(BCMdrive & BCMcsv, True, False)
Set objTXT = objFSO.OpenTextFile(BCMdrive & BCMcsv, 1)
sLines = Split(objTXT.ReadAll, vbCvLf)
objTXT.Close
iNumberOfLines = UBound(sLines)
If iNumberOfLines > 1 Then
Set objTXT = objFSO.OpenTextFile(objCSV, 2)
For i = 1 To iNumberOfLines
objTXT.WriteLine sLines(i)
Next
objTXT.Close
End If
...Set objects = nothing ...
SECOND -- blows up at the first line input:
...
BCMcsv = Dir$(BCMdrive & BCMtext)
Dim f1 As Long
Dim f2 As Long
Dim strLine As String
f1 = FreeFile
Open BCMdrive & BCMcsv For Input As #f1
f2 = FreeFile
Open BCMdrive & "tempBCM.txt" For Output As #f2
Line Input #f1, strLine
Do While Not EOF(1)
Line Input #f1, strLine
Print #f2, strLine
Loop
Close #f1
Close #f2
...
|
|
|
|
|
I wrote this just now and it seems to work fine.
Give it a try ...
Dim sr As System.IO.StreamReader
Dim sw As System.IO.StreamWriter
Dim sLine As String
Dim iCount As Integer = 0
sr = New System.IO.StreamReader("C:\temp\file1.txt")
sw = New System.IO.StreamWriter("C:\temp\file2.txt")
sLine = sr.ReadLine()
While Not (sLine Is Nothing)
iCount = iCount + 1
If (iCount > 1) Then
sw.WriteLine(sLine)
End If
sLine = sr.ReadLine()
End While
sr.Close()
sr.Dispose()
sw.Close()
sw.Dispose()
|
|
|
|
|
thanks dave -
i'm getting a "compile error: type mismatch" error at the
sr = New System.IO.StreamReader(mydrive & myfile)
line. also, the only way it seems to take without showing red text in the module is to delete the "New" i'm on excel 2003 but am not seeing any project references that would seem to apply here. please advise, thnx!
|
|
|
|
|
Sorry my example was written in Visual Studio 2010 VB.NET
I did not realize you were looking for a solution in Excel VBA.
If I get time, I'll try to post an example in Excel VBA. I should have picked up on it when you posted your code sample.
My bad.
|
|
|
|
|
no worries, dave - i appreciate your help here, thnx!
|
|
|
|
|
...yes, did research this a little and discovered this was a .net contstuct. we dont have that available here, otherwise would have been happy to explore it.
|
|
|
|
|
got it, dave -
final code is below; thnx for your help!
|
|
|
|
|
Great to know that you solved your problem.
The folks here are very helpful.
|
|
|
|
|
From your description, I think the lines in your CSV file are not delimited by CRLF, but only LF. That would explain why you are able to open / save in Notepad, and use the file.
HTH
Happiness will never come to those who fail to appreciate what they already have. -Anon
|
|
|
|
|
thanks chandraram -
thought i had tried that and didnt work either. will try it again now...
|
|
|
|
|
thanks again, ChandraRam -
did try to work with the LF specification, and that is how the csv is delimited, however still getting the "input past end of file" error. my "second" code attempt, posted earlier:
...
BCMcsv = Dir$(BCMdrive & BCMtext)
Dim f1 As Long
Dim f2 As Long
Dim strLine As String
f1 = FreeFile
Open BCMdrive & BCMcsv For Input As #f1
f2 = FreeFile
Open BCMdrive & "tempBCM.txt" For Output As #f2
Line Input #f1, strLine 'ignore first line
Do While Not EOF(1)
Line Input #f1, strLine
Print #f2, strLine
Loop
Close #f1
Close #f2
...
does actually seem to work down to the "Line Input #f1, strLine" line, but it is reading the entire csv file at this point; doesnt seem to be parsing it line by line... ??
|
|
|
|
|
Not sure where you have taken into account that the delimiter is LF instead of CRLF in your code...
FYI,
Line Input
reads a line of text until it encounters a CR, which in this case is probably only at the end of the file.
Happiness will never come to those who fail to appreciate what they already have. -Anon
|
|
|
|
|
right, apparently not in this code. was trying to work with "sLines = Split(objTXT.ReadAll, vbCvLf)" in the first code above; cant seem to get either to work right
|
|
|
|
|
dubscat wrote: "sLines = Split(objTXT.ReadAll, vbCvLf)" Should it not be vbCRLF?
Also, did you try splitting with just vbLF? If your CSV is delimited with LF, surely that should work?
Happiness will never come to those who fail to appreciate what they already have. -Anon
|
|
|
|