It sounds like your application is using early-binding with Excel - there is a reference directly to the DLL in the appication.
Can the application be rewritten to use late-binding and simply use whatever version of Excel is on the client computer?
Yes, this will probably required a great deal of work, but, it may also solve the problem.
I encountered a similar problem with Micrsoft ActiveX Data objects; my application was referencing a version higher than the end-user had available. So, I used a CreateObject call rather than define the object directly.
I am struggling with merged cells. If I have a single cell and the text is long, then when I check wrap text then the text is wrapped and the height of the line is increased. When I have 2 cells merged, and the text is too long, then it does wrap, but it cuts off, and the line height is not adjusted so that all the text is displayed.
How do I get this to work for merged cells the same as for single cells.
Hello all,I'm new to VB,I found problem on converting the following code to VB.NET. I'm using the Visual Studio 2003 here. Anyone please give me a solution for the following code I found in the main module :
Public Declare Function GetPrivateProfileSection Lib "KERNEL32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long<br />
Public Declare Function GetPrivateProfileSectionNames Lib "kernel32.dll" Alias "GetPrivateProfileSectionNamesA" (ByVal lpszReturnBuffer As String, ByVal nSize As Long, ByVal lpFileName As String) As Long<br />
Public Declare Function GetPrivateProfileString Lib "KERNEL32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long<br />
Public Declare Function GetTempPath Lib "KERNEL32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long<br />
Public Declare Function GetTempFileName Lib "KERNEL32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long<br />
Public Declare Function SetFileAttributes Lib "KERNEL32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long<br />
Public Declare Function GetShortPathName Lib "KERNEL32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long<br />
Public Declare Function GetDesktopWindow Lib "user32" () As Long<br />
Public Declare Function GetFileTitle Lib "comdlg32.dll" Alias "GetFileTitleA" (ByVal lpszFile As String, ByVal lpszTitle As String, ByVal cbBuf As Integer) As Integer<br />
Thank you in advance for giving me some solution for the above convertion.
Do you mean that I can found the solution from that website? I do try to copy the code there and paste to test but it can't works. They are using something call "Marshal" in the code but I don't know how it goes. Can you provide further solution on the issue?
The Marshal class provides methods, properties and attributes to tell the .NET CLR how to marshal parameters, among other things, back forth between managed and unmanaged code. An full explanation of how this works is well beyond the capacity of a forum post. It'd take something more like a small book to describe it all.
Can I ask why you're even bothering with these?? Most of these functions have equivilents in the .NET Base Class Library and some of the functions have been obsolete.
The following is the code I found from pinvoke, but there is a few error on it display on my Visual Studio 2003 developer tools:
Private Const MaxIniBuffer As Integer = &H7FFF<br />
Public Shared Function ReadSection(ByVal filename As String, ByVal section As String) As System.Collections.Specialized.NameValueCollection<br />
Dim pBuffer As IntPtr<br />
Dim bytesRead As Byte<br />
Dim sectionData As New System.Text.StringBuilder(MaxIniBuffer)<br />
Dim values As New System.Collections.Specialized.NameValueCollection<br />
Dim pos As Integer ' seperator position<br />
Dim name, value As String<br />
If (Not System.IO.File.Exists(filename)) Then<br />
Return Nothing<br />
End If<br />
'get a pointer to the unmanaged memory<br />
pBuffer = Marshal.AllocHGlobal(MaxIniBuffer)<br />
bytesRead = GetPrivateProfileSection(section, pBuffer, MaxIniBuffer, filename)<br />
If (bytesRead > 0) Then<br />
For i As Integer = 0 To bytesRead - 1<br />
sectionData.Append(Convert.ToChar(Marshal.ReadByte(pBuffer, i)))<br />
sectionData.Remove(sectionData.Length - 1, 1)<br />
For Each line As String In sectionData.ToString().Split(Convert.ToChar(0))<br />
' locate the seperator<br />
pos = line.IndexOf("=")<br />
If (pos > -1) Then<br />
'get values<br />
name = line.Substring(0, pos)<br />
value = line.Substring(pos + 1)<br />
' add to collection<br />
values.Add(name, value)<br />
End If<br />
values = Nothing<br />
End If<br />
' release the unmanaged memory<br />
' return collection or Nothing if we weren't able to get anything<br />
Return values<br />
Name "Marshal"is not declared.
Value of type 'System.IntPtr' cannot be converted to 'String'.
Do you know how to solve this? I'm not really understanding how the flow of the data goes here in the above code.
This isn't possible since the user wouldn't be able to run the applicaiton because he/she wouldn't be able to read the key.
2)store the key in differnt formats
The different "format" would have to be an encrypted version of the key.
But, since you're putting this key in the regsitry, what's to stop the user from just exporting the data from the registry and importing it into another machine and running your app?? Nothing!! Since your key probably isn't generated from any machine specific data, your code will never know that it's an illegal copy.
Basically, any system you come up with yourself is going to be easily defeatable. Use a third party package instead. It's still no guarantee that your code won't be copied illegally, since any protection scheme can be cracked. Click here...[^]