MS Access, Compile error: Type mismatch, SetWindowPos - type-mismatch

Currently 5 users of this database. Database works fine for everyone, except one user who received a new laptop. User with new laptop receives error message: Compile error: Type mismatch, for variable h.
Code:
'====================================
' Global Declarations
'====================================
Option Compare Database
Option Explicit
'NOTE: The following "Declare" statement is case sensitive.
Declare PtrSafe Sub SetWindowPos Lib "user32" (ByVal hwnd&, _
ByVal hWndInsertAfter&, _
ByVal X&, ByVal Y&, ByVal cX&, _
ByVal cY&, ByVal wFlags&)
'Moves MS Access window to top of Z-order.
Global Const HWND_TOP = 0
'Values for wFlags.
Global Const SWP_NOZORDER = &H4 'Ignores the hWndInsertAfter.
Function SizeAccess(cX As LongPtr, cY As LongPtr, _
cHeight As LongPtr, cWidth As LongPtr)
Dim h As LongPtr
'Get handle to Microsoft Access.
h = Application.hWndAccessApp
'Position Microsoft Access.
SetWindowPos h, HWND_TOP, cX, cY, cWidth, _
cHeight, SWP_NOZORDER
End Function
I removed the LongPtr declarations, only to receive the error message "project must be updated for use on 64-bit systems. Update declarations and mark them with the PtrSafe attribute." So I change the code back.
Any suggestions for why user is receiving this message?
Expecting the MS Access form to automatically display upon opening application.

Related

Delphi Set of Enumeration

I'm trying to filter my logging. If a log (or message) type is in the options, I want to send it to the log, otherwise exit.
The compilation fails on the "if not MessageType in..." line with:
"[dcc32 Error] uMain.pas(2424): E2015 Operator not applicable to this operand type"
I think it must be possible (and reasonably simple) based on the Include/Exclude functions, which I tried looking at but couldn't find anywhere (i.e. Include(MySet, llInfo); ).
My declaration are as follows:
type
TLogLevel = (llDebug, llError, llWarn, llInfo, llException);
TLogOptions = set of TLogLevel;
var
FLogOptions: TLogOptions;
procedure TfrmMain.Log(const s: String; MessageType: TLogLevel;
DebugLevel: Integer; Filter: Boolean = True);
begin
if not MessageType in FLogOptions then
exit;
mmoLog.Lines.Add(s);
end;
You need parentheses around the set operation because of operator precedence. The compiler is parsing it as if not MessageType, which is not a valid operation. If you put parentheses around the set test, the compiler can parse it correctly.
if not (MessageType in FLogOptions) then
This is a common issue, and is not specific to set types. For instance, you can get the same error with the following express as well.
if not 1 = 2 and 2 = 3 then
Adding parentheses around the two equality tests will correct the error.
if not (1 = 2) and (2 = 3) then
For more information, you can see the documentation for Operator Precedence

Is there a way to find customized permissions in TFS

We are planning to move our Team Foundation Server server to a new domain, and as such any customized permissions will need to be updated/corrected.
I was wondering if there was a tool, or some sample code I could use to scan through TFS files and folders (as seen in Source Control Explorer) to find permissions that are different from the default.
Note that unfortunately, we are still using TFS 2010.
What I would like is to get or build a summarized list saying at this path, security was changed for User X to a, User Y to b, etc. and if inheritance was turned off. If a path did not have any security changes, then I would prefer it if it is not included in the report. I can build code to strip that out if necessary as long as the report is in an editable format (e.g. csv, xml, html, txt)
I am quite willing to create the tool myself, I am just unsure where to start. It seems like the libraries for this are so large and often these things are not well documented. If I create this, I will share what I can.
Thank you
You may try Team Foundation Sidekicks. Team Foundation Sidekicks includes Permission Sidekick, which provides the following features:
Select user whose effective permissions are to be reviewed
View Team Foundation Server groups user is a member of (Windows
domain groups are not included)
View user's global TFS server permissions
Select Team project to view project specific effective permissions
View user's Team project's permissions
Select project's version control folder/file and view effective
version control permissions for that item (including indication
whether permissions are inherited or explicitly set)
Select project's area and view effective permissions for that area
For every effective permissions display, view a reason for every
effective permission setting - namely, for which groups Allow/Deny
permissions are set and therefore what effective permission is based
on
I ended up writing code to do this. I'm sorry it took so long to post this.
It creates a text file that specifies the security on every item in TFS that has explicit security. It may give more information that needed, but worked well for my needs.
If you make use of this, you should replace "TFSServer" with your actual server name, and "CollectionName" with the actual source code collection name which is typically "DefaultCollection".
Note that this was written in VB, and requires the following references.
Default references of System, System.Core, XML, and XML.Linq are included.
From "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0"
Microsoft.TeamFoundation.Client
Microsoft.TeamFoundation.Common
Microsoft.TeamFoundation.VersionControl.Client
Option Explicit On
Option Strict On
Option Infer Off
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.VersionControl.Client
Imports Microsoft.TeamFoundation.Framework.Client
Imports System.IO
Namespace EnumerateTFSSecurity
Friend Class Program
Private Shared UpdateConsoleIndex As Integer
Shared Sub Main()
Try
Dim tfs As TfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(New Uri("http://TFSServer:8080/tfs/CollectionName"))
Dim OutputFileName As String = ".\EnumTFSSec.txt"
If Command().Length <> 0 Then
OutputFileName = Command()
End If
tfs.EnsureAuthenticated()
Dim VersionControl As VersionControlServer = tfs.GetService(Of VersionControlServer)()
Dim OutputFile As StreamWriter = New StreamWriter(OutputFileName)
Dim AllProjs() As TeamProject = VersionControl.GetAllTeamProjects(True)
For Each TeamProj As TeamProject In AllProjs
GetChildItems(VersionControl, TeamProj.ServerItem, OutputFile)
OutputFile.Flush()
Next
Catch e As Exception
Dim ex As String = e.Message
Console.WriteLine("!!EXCEPTION: " & e.Message)
Console.WriteLine("Continuing... ")
End Try
Console.WriteLine("========")
Console.Read()
End Sub
Private Shared Sub GetChildItems(VersionControl As VersionControlServer, ItemPath As String, OutputFile As StreamWriter)
Dim Items() As Item = VersionControl.GetItems(ItemPath & "/*").Items
Dim FolderPaths As Specialized.StringCollection
Dim FilePaths As List(Of String)
FolderPaths = New Specialized.StringCollection
FilePaths = New List(Of String)
GetSecurityInfo(VersionControl, {ItemPath}, OutputFile)
For Each Item As Item In Items
If Item.ItemType = ItemType.Folder Then
FolderPaths.Add(Item.ServerItem)
Else
FilePaths.Add(Item.ServerItem)
End If
Next
For Each Folder As String In FolderPaths
GetChildItems(VersionControl, Folder, OutputFile)
Next
If FilePaths.Count <> 0 Then
GetSecurityInfo(VersionControl, FilePaths.ToArray, OutputFile)
End If
End Sub
' Define other methods and classes here
Private Shared Sub GetSecurityInfo(VersionControl As VersionControlServer, ByVal ItemPaths() As String, OutputFile As StreamWriter)
Dim result As List(Of String) = New List(Of String)
Dim SecurityList() As ItemSecurity
Dim SecurityInfo As StringBuilder = Nothing
Dim Clearstringlength As Integer
Dim ConsoleText As String
Try
SecurityList = VersionControl.GetPermissions(ItemPaths, RecursionType.None)
SecurityInfo = New StringBuilder
If SecurityList IsNot Nothing AndAlso SecurityList.Length <> 0 Then
For Each ItemSecurity As ItemSecurity In SecurityList
With ItemSecurity
If .Inherit = False Then
SecurityInfo.Append(" - Inherit: False")
End If
For Each Entry As AccessEntry In .Entries
If (Entry.Allow.Length <> 0 OrElse Entry.Deny.Length <> 0) Then
SecurityInfo.AppendLine()
SecurityInfo.AppendLine(" Identity: " & Entry.IdentityName)
If Entry.Allow.Length <> 0 Then
SecurityInfo.Append(" Allow: ")
For Each Value As String In Entry.Allow
SecurityInfo.Append(Value & "; ")
Next
SecurityInfo.Remove(SecurityInfo.Length - 2, 2)
If Entry.Deny.Length <> 0 Then
SecurityInfo.AppendLine()
End If
End If
If Entry.Deny.Length <> 0 Then
SecurityInfo.Append(" Deny: ")
For Each Value As String In Entry.Deny
SecurityInfo.Append(Value & "; ")
Next
SecurityInfo.Remove(SecurityInfo.Length - 2, 2)
End If
End If
Next
If SecurityInfo.Length <> 0 Then
SecurityInfo.AppendLine()
End If
End With
If UpdateConsoleIndex Mod 25 = 0 Then
ConsoleText = "Item:" & ItemSecurity.ServerItem
Clearstringlength = If(Console.CursorTop = 0, 0, Console.CursorTop * Console.BufferWidth - 1) - ConsoleText.Length
Console.CursorTop = 0
Console.CursorLeft = 0
If Clearstringlength > 0 Then
ConsoleText &= New String(" "c, Clearstringlength)
End If
Console.WriteLine(ConsoleText)
End If
If SecurityInfo IsNot Nothing AndAlso SecurityInfo.Length > 0 Then
If UpdateConsoleIndex <> 0 Then
OutputFile.WriteLine()
End If
OutputFile.Write("Item:" & ItemSecurity.ServerItem)
OutputFile.Write(SecurityInfo.ToString())
SecurityInfo.Clear()
End If
UpdateConsoleIndex += 1
Next
End If
Catch e As Exception
Dim ex As String = e.Message
Console.WriteLine("!!EXCEPTION: " & e.Message)
Console.WriteLine("Continuing... ")
End Try
End Sub
End Class
End Namespace

Delphi DLL-use functions designed to return a set of values Integer Record

Currently need to use Delphi to write a DLL, so that the main program calls to the specified place in the removable disk in a file,
Main program designed to VC + +, so use Strut way to call the DLL's data as round!!
Current problems encountered when the main program calls my DLL, the incoming group A Record, and other functions has been dealt with, to return the group B Record,
But using Delphi written DLL, can receive group A Record, but returned group B, but always errors!!
The following is the code for the DLL function, would like to ask if anyone encountered such problems can help point to mention turned a deaf ear
Thanks! !
enter code here
library usbdll;
uses
Windows,
SysUtils,
Classes;
{$R *.res}
Type
p_fin=^TSfin;
TSfin = record //A group of Record is the main program calls incoming Record Type
ST_act:Integer;
pathlen:Integer;//Pass true path length, so that I can get to the far left pathlen, then to remove the rear garbled
Id_hand:Integer;
Id_tail:Integer;
path: PWideChar://The reason why the file path Pwidechar do use guidelines because another branch dll is passed to the main program main program <file path + unicode>, is behind the path and dragging a bunch of gibberish characters
Type
p_out=^TRfout;//B Record is set to return to the main program of the Record Type
TRfout= Record
ST_act:Integer;
ST_move:Integer;
Revis:Integer;
Crchk:Integer;
end;
//The following is my comment out.
// The use of the test in two ways, directly back to the group B Record, does not receive group A Record,A group that does not receive Record, when the main program a call, immediately return the relevant data, the results are normal.
(*
function RFoutEt(test:p_out):Boolean;stdcall; //ok Function writing mode
begin
test^.ST_act:=14;
test^.ST_move:=10;
test^.Revis:=12;
test^.Crchk:=8;end;exports RFoutEt;
procedure RFoutE(out Result:TRfout);cdecl; //ok Procedure writing mode
begin
Result.ST_act:=14;
Result.ST_move:=10;
Result.Revis:=12;
Result.Crchk:=8;end;exports RFoutEt;
*)
// Actually, I need to charge the main program to my group A Record datain order to deal with post-op, get really want to move the file to specify the true path,and ultimately return to group B Record.
function RFoutE(ap_sendin:p_fin;num:Integer):TRfout;stdcall; //error
var
str_tmp,str_tmp2,temi_diry:string;
i,copyNum:Integer;
arr: array[0..100] of Char;
begin
//Program by adding the following {} after paragraph, Result is not an empty value is displayed to access illegal address,causing abnormal program termination.
{
StrCopy(arr,Pchar(ap_sendin^.path));
repeat
str_tmp:=temi_diry;//Use the file path string char array A group referred to in the PWidechar removed
str_tmp2:=arr[i];
Inc(i);
until i>=ap_sendin.pathlen;
copyNum:=Prs_Filecopy(temi_diry;ap_sendin^.path);//A group of Record with associated data to complete the move of the specified file
}
Result.ST_act:=4;//The following four lines of words alone are able to return data
Result.ST_move:=0;
Result.Revis:=2;
Result.Crchk:=copyNum;end;
PS. Following is a test using VC + + to try more than one function is normal demand
struct Sfin{
int ST_act;
int pathlen;
int Id_hand;
int Id_tail;
wchar_t *path;
};
struct Rfout{
int ST_act;
int ST_move;
int Revis;
int Crchk;
};
Rfout RFoutE(struct Sfin *a, int num)
{
int ret = 1;
Rfout OutStruct;
copyNum = Prs_Filecopy(temi_diry, inAnow, Anow->path);
ret=1;
if(ret==1){
OutStruct.ST_act =14;
OutStruct.ST_move =10;
OutStruct.Revis = 12;
OutStruct.Crchk = 8;
Anow = freeA(Anow);
}
return OutStruct;
}
There is no standard ABI for larger than machine word sized return values. And Delphi uses a different ABI from any other compiler that I've encountered so you'll have no luck returning large records that way.
You'll need to return the record as an out parameter rather than a function return value. Once you make that change, all will be well.
It also looks like your C++ functions use cdecl rather than stdcall.

F# signature files - defining constructor parameters

I'm running into an error when creating a signature file for an F# script file which I can't quite work out.
To replicate, create a new F# class library and add a file, Test.fs:
namespace Signatures
open System
type Test (id : Guid, name : string) =
member this.Id = id
member this.Name = name
This will build fine. Then create a new signature file above it, Test.fsi:
namespace Signatures
open System
type Test =
new : (Guid * String) -> Test
member Id : Guid
member Name : String
This will now not build with the error Module 'Signatures' requires a value 'new : (Guid * String) -> Test (this is different to the error you get if the constructor signature is different in the two files). The only real documentation I can find on defining constructors in the signature file is MSDN and that deals with parameterless constructors.
If you hover over Test in the .fs file the constructor's signature matches the one in the .fsi file. I've also tried changing the constructor so that it is not implicit with no joy.
I'm using the VS2012 RC, and have tried .Net 4 and 4.5.
It's too long for a comment, so I post it as an answer.
Test's constructor receives two arguments as its parameters, not one argument which is a tuple. I admit that * between arguments looks confusing. But the signature Guid -> string -> Test is even worse than that. Constructors should get some inputs and produce a new type instance. Curried form and partial application don't make sense in the context of constructors.
I think the brackets help clarify here.
type Test (id : System.Guid, name : string) =
member this.Id = id
member this.Name = name
produces new : id:Guid * name:string -> Test while
type Test (tuple: System.Guid * string) =
let id, name = tuple
member this.Id = id
member this.Name = name
gives me new : tuple:(Guid * string) -> Test in an FSI session. I use F# 2.0/MonoDevelop 3.0 for the record.
Regarding creating type signatures, I usually send code into F# Interactive and copy produced signatures to fsi files to avoid mistakes. If the tooltips and F# Interactive show type signatures wrongly on VS2012 RC, you should report at fsbugs (at) microsoft (dot) com.
An extra pair of parens can be significant. Consider the following:
type T =
static member Add(x, y) = x + y
static member AddTuple((x, y)) = x + y
which, in C#, appear as
int Add(int x, int y)
int AddTuple(Tuple<int, int> arg)
Tangentially, you can't do something similar in a constructor:
type Test((id, name)) = class end //DOESN'T COMPILE
Since constructors already take arguments in tupled form you would expect 'a * 'b and ('a * 'b) to be different things. This is consistent with method syntax.
If anyone wants to explain why this works, I'd love to know but I just started fiddling with the syntax to see if I could get anything more revealing out of the compiler.
If I remove the brackets are the tuple, it compiles, i.e. change this:
new : (Guid * String) -> Test
To:
new : Guid * String -> Test

How can i put more than one Crystal Report into one Crystal Report viewer ?

So here is the thing ..
I wrote a c# application to generate monthly Attendance Reports for each employee with his own details
I want to be able to do this once for all employees and view the report grouped by name
so when I select the customer name from the crystal report sub tree I get his monthly Attendance Report
I don't really know how to use the sub tree in crystal report ... is it possible to something like that ?
the goal from all this is to be able to print all reports at once in one click
This is not exactly what you asked for but I am going to post it because it may work for you. I did for me in a similar situation. Also sorry about the VB syntax
This will allow you to create your reports as PDFs using the Crystal Reports engine. Basically it will allow you to create multiple PDF using a loop, which can then be printed automatically.The Export PDF Sub will write the file to disk and then open it with the default pdf reader. The print PDF function will automaticaly print the PDF files that were saved to disk. This is not a perfect solution but I hope that it at least gets you closer to what you are trying to accomplish.
Public Class PDFCR
Private Const SW_SHOWNORMAL As Integer = 2
<DllImport("shell32")> _
Public Shared Function ShellExecute(ByVal hWnd As IntPtr, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Integer) As IntPtr
End Function
Public Shared Sub ExportPDF(ByVal crDOC As ReportDocument, ByVal FilePath As String)
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = FilePath
CrExportOptions = crDOC.ExportOptions
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions
CrExportOptions.FormatOptions = CrFormatTypeOptions
crDOC.Export()
Process.Start(FilePath)
End Sub
Public Shared Function PrintPDF(ByVal FilePath As String) As Boolean
If IO.File.Exists(FilePath) Then
If ShellExecute(CType(1, IntPtr), "Print", FilePath, "", _
Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32 <= 32 Then
Return False
Else
Return True
End If
Else
Return False
End If
End Function
End Class
I was having trouble getting the Imports to show in this code block so here they are in plain text.
Imports System.IO
Imports System.Management
Imports CrystalDecisions.Shared
Imports System.Runtime.InteropServices
Imports CrystalDecisions.CrystalReports.Engine
If you add a GROUP to your report on your Employee Name field, this will (by default) create the group tree you are looking for.
From there, code-wise, it can be turned off, but you should see the group tree by default if your report has any groups in it.
The problem seems to be with the report not being grouped on Employee Name.

Resources